标签: uiactionsheet

UIActionSheet取消按钮奇怪的行为

我有一个UIBarButtonItem打开一个动作表,为用户提供有关做什么的选择.除非我尝试点击"取消"按钮,否则一切都按预期工作.按钮的目标似乎已从应该的位置向上移动.我只能通过单击"取消"和"确定"按钮中间的某个位置来激活它.

我已经尝试过在其他应用程序中的动作表,它们工作正常,所以它不仅仅是我的大拇指.操作表在UIViewController中打开

- (void)showOpenOptions
{
    UIActionSheet *sheet = [[UIActionSheet alloc] 
    initWithTitle:NSLocalizedString(@"Open link in external application?", @"Open in external application")
    delegate:self
    cancelButtonTitle:NSLocalizedString(@"Cancel", @"Cancel")
    destructiveButtonTitle:NSLocalizedString(@"Open Link", @"Open Link")
    otherButtonTitles:nil];

    [sheet showInView:self.view];
    [sheet release];
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uiactionsheet ios

116
推荐指数
5
解决办法
2万
查看次数

通过传入数组而不是varlist来创建UIActionSheet的"otherButtons"

我有一个字符串数组,我想用于UIActionSheet上的按钮标题.不幸的是,方法调用中的otherButtonTitles:参数采用可变长度的字符串列表,而不是数组.

那我怎么能把这些标题传递到UIActionSheet呢?我见过的解决方法是将nil传递给otherButtonTitles :,然后使用addButtonWithTitle:单独指定按钮标题.但这有将"取消"按钮移动到UIActionSheet上的第一个位置而不是最后一个位置的问题; 我希望它是最后一个.

有没有办法1)传递一个数组代替一个变量的字符串列表,或者2)将取消按钮移动到UIActionSheet的底部?

谢谢.

iphone uialertview uiactionsheet ios

110
推荐指数
2
解决办法
3万
查看次数

UIActionSheet iOS Swift

如何在iOS Swift中执行UIActionSheet?这是我编码UIActionSheet的代码.

@IBAction func downloadSheet(sender: AnyObject)
{
    let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: .actionSheet) 

    let saveAction = UIAlertAction(title: "Save", style: .default, handler: 
    {
        (alert: UIAlertAction!) -> Void in
        println("Saved")
    })

    let deleteAction = UIAlertAction(title: "Delete", style: .default, handler:
    {
        (alert: UIAlertAction!) -> Void in
        println("Deleted")
    })

    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: 
    {
        (alert: UIAlertAction!) -> Void in
        println("Cancelled")
    })
    optionMenu.addAction(deleteAction)
    optionMenu.addAction(saveAction)
    optionMenu.addAction(cancelAction)
    self.presentViewController(optionMenu, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

我希望我的代码清楚......我欢迎对此代码提出更好的建议.

uiactionsheet ios swift

89
推荐指数
8
解决办法
9万
查看次数

ActionSheet无法使用iPad

我在我的应用程序中使用ActionSheet.在我的iPhone上它可以工作,但它不在iPad模拟器上.

这是我的代码:

@IBAction func dialog(sender: AnyObject) {

    let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: .ActionSheet)
    let deleteAction = UIAlertAction(title: "Delete", style: .Default, handler: {

        (alert: UIAlertAction!) -> Void in
        println("Filtre Deleted")
    })

    let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
        (alert: UIAlertAction!) -> Void in
        println("Cancelled")
    })

    optionMenu.addAction(deleteAction)
    optionMenu.addAction(cancelAction)

    self.presentViewController(optionMenu, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

而我的错误:

由于未捕获的异常'NSGenericException'而终止应用程序,原因是:'您的应用程序已呈现样式UIAlertControllerStyleActionSheet的UIAlertController().具有此样式的UIAlertController的modalPresentationStyle是UIModalPresentationPopover.您必须通过警报控制器的popoverPresentationController为此弹出窗口提供位置信息.您必须提供sourceView和sourceRect或barButtonItem.如果在显示警报控制器时不知道此信息,您可以在UIPopoverPresentationControllerDelegate方法-prepareForPopoverPresentation中提供它.

uiactionsheet ipad ios swift

78
推荐指数
5
解决办法
2万
查看次数

Swift UIAlertController - > ActionSheet iPad iOS8崩溃

目前我的ActionSheet遇到了大麻烦.在iPhone上它运行良好,但在iPad上它只会崩溃

我用一个按钮创建一个新项目

import UIKit

extension ViewController : UIActionSheetDelegate {

    func actionSheet(actionSheet: UIActionSheet, didDismissWithButtonIndex buttonIndex: Int) {

        if actionSheet.tag == 0 {
            if buttonIndex == 1 {
                // doing something for "product page"
            } else if (buttonIndex == 2) {
                // doing something for "video"
            }
        }
    }

}

class ViewController: UIViewController, UIActionSheetDelegate {
    @IBAction func test(sender: AnyObject) {

        let systemVersion: NSInteger = (UIDevice.currentDevice().systemVersion as NSString).integerValue
        if systemVersion < 8 {
            // iOS7:
            let action:UIActionSheet = UIActionSheet(title: "Change Map Type", delegate: …
Run Code Online (Sandbox Code Playgroud)

iphone uiactionsheet ipad swift

60
推荐指数
3
解决办法
3万
查看次数

创建UIActionSheet

我想创建这种菜单,当然还有其他菜单按钮.是否有任何默认的viewcontroller代表它,或者我必须自己获取图像并创建它.

在此输入图像描述

objective-c uiactionsheet ios

58
推荐指数
3
解决办法
8万
查看次数

在iOS8 - iOS11中从动作表的委托中以模态方式呈现视图控制器

所以我注意到在iPad上的iOS8 beta 3(更新:仍然发生在iOS 11.2中),当尝试从a的委托方法中呈现视图控制器时UIActionSheet,"没有"发生并且日志消息输出到调试控制台,说明在转换警报控制器时尝试演示:

Warning: Attempt to present <UIViewController: 0x...> on <ViewController: 0x...> which is already presenting <UIAlertController: 0x...>
Run Code Online (Sandbox Code Playgroud)

uikit uiactionsheet ios uialertcontroller

58
推荐指数
2
解决办法
3万
查看次数

从IOS 8在UIActionSheet中添加UIPickerView无法正常工作

我正在补充UIPickerView,UIActionsheet但它的工作完美,ios 7但没有工作ios 8.请帮我解决这个问题.

在这里我附上了截图.在此输入图像描述

谢谢

我正在使用以下代码.

UIActionSheet *actionSheet;
NSString *pickerType;

- (void)createActionSheet {

    if (actionSheet == nil) {
        // setup actionsheet to contain the UIPicker
        actionSheet = [[UIActionSheet alloc] initWithTitle:@"Please select" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
        actionSheet.backgroundColor = [UIColor clearColor];

        UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
        pickerToolbar.barStyle = UIBarStyleBlackOpaque;
        [pickerToolbar sizeToFit];

        UIImageView *imageObj = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 40)];
        imageObj.image = [UIImage imageNamed:@"header.png"];
        [pickerToolbar addSubview:imageObj];

        UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom]; …
Run Code Online (Sandbox Code Playgroud)

iphone uipickerview uiactionsheet ios ios8

52
推荐指数
4
解决办法
3万
查看次数

如何使用UIAlertController替换UIActionSheet?

我正在维护一个基于SDK 6.0的旧iOS项目.

这个项目的方法称为

-(void) showComboBox:(UIView*)view:withOptions:(NSDictionary*)options

用于显示组合框.为了实现这一目标,它使用了UIActionSheet,这在iOS8上已弃用.

我的解决方案是这样的:

        if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8) {
        UIAlertController* alertController = [UIAlertController 
           alertControllerWithTitle:@"title" 
           message:@"message" 
           preferredStyle:UIAlertControllerStyleActionSheet];

        UIAlertAction* item = [UIAlertAction actionWithTitle:@"item" 
           style:UIAlertActionStyleDefault 
           handler:^(UIAlertAction *action) {
            //do something here 
            //inform the selection to the WebView 
            ...
            [alertController dismissViewControllerAnimated:YES completion:nil];
        }];

        UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            [alertController dismissViewControllerAnimated:YES completion:nil];
        }];

        [alertController addAction:item];
        [alertController addAction:cancelAction];
        //I am not sure whether it's the right way
        if ([view.nextResponder isKindOfClass:UIViewController.class]) {
            UIViewController* vc = (UIViewController*)view.nextResponder;
            [vc presentViewController:alertController animated:YES completion:nil]; …
Run Code Online (Sandbox Code Playgroud)

objective-c uiactionsheet ios uialertcontroller

51
推荐指数
4
解决办法
5万
查看次数

来自Popover的UIActionSheet与iOS8 GM

在尝试从popover显示UIActionSheet时,是否有人收到此消息?

您的应用程序提供了样式UIAlertControllerStyleActionSheet的UIAlertController().具有此样式的UIAlertController的modalPresentationStyle是UIModalPresentationPopover.您必须通过警报控制器的popoverPresentationController为此弹出窗口提供位置信息.您必须提供sourceView和sourceRect或barButtonItem.如果在显示警报控制器时未知此信息,则可以在UIPopoverPresentationControllerDelegate方法-prepareForPopoverPresentation中提供该信息.

在GM之前,我使用了一些解决方法将UIActionSheet转换为UIAlertController,这很好用.然而,似乎Apple试图解决UIActionSheet问题,我不想使用我的解决方法 - 但似乎我别无选择......

uiactionsheet uipopovercontroller ios ios8 uialertcontroller

47
推荐指数
3
解决办法
2万
查看次数