【问题标题】:iPad UIActionSheet in modalView problemiPad UIActionSheet 在modalView 问题
【发布时间】:2011-07-20 18:54:58
【问题描述】:

我在 iPad 的 modalView 中使用 ActionSheet。 我从导航控制器上的 UIBarButton 显示它。 第一个问题:如果我点击 10 次,它会显示 10 个 actionSheet,这是一个问题。

第二个问题:在导航栏的右边,有一个完成按钮。 当我点击 actionSheet 按钮,出现 actionsheet,然后我点击 DONE 按钮,modalView 被关闭,actionsheet 保持在屏幕上,然后应用程序崩溃。

显示操作表的代码:

UIActionSheet *iPadActionButton = [[UIActionSheet alloc] initWithTitle: @""
                                                              delegate: self
                                                     cancelButtonTitle: nil
                                                destructiveButtonTitle: nil
                                                     otherButtonTitles: @"option 1", @"option 2", @"option ", nil];

iPadActionButton.destructiveButtonIndex = 2;
[iPadActionButton showFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];
[iPadActionButton setTag:200];
[iPadActionButton release];

关于如何解决这些问题的任何想法?

【问题讨论】:

    标签: iphone ipad uiview modal-dialog uiactionsheet


    【解决方案1】:

    我会保留对 UIActionSheet 的引用作为类属性。

    在您的标题中:

    @interface ClassName: UIViewController {
        UIActionSheet *iPadActionButton;
    }
    
    @property (nonatomic, retain) UIActionSheet *iPadActionButton;
    

    这将做两件事:

    1) 允许您使用 [iPadActionButton visible] 属性检查它是否已经可见。

    2) 允许您在 viewWillDisappear:animated: 中正确处理它:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-03
      • 1970-01-01
      • 2011-05-26
      相关资源
      最近更新 更多