当显示UIAlertController(actionsheet)iOS8时出现运行时异常

萨巴雷什

当我iOS8 Beta5 + Xcode6中显示UIAlertController(ActionSheet)时,将出现运行时异常

此错误仅在iPad设备中发生

使用UIAlertController时出现波纹管异常。

*由于未捕获的异常'NSGenericException'而终止应用程序,原因:'UIPopoverPresentationController(<_UIAlertControllerActionSheetRegularPresentationController:0x15794370>)在演示之前应设置非null的sourceView或barButtonItem。

我的显示ActionSheet的代码如下

     // Cancel Button
      UIAlertAction *actionCancel = [UIAlertAction
                                               actionWithTitle:NSLocalizedString(@"IDS_LABEL_CANCEL", nil)
                                               style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                                                   // cancel
                                                   //action handler
                                                   [self actionHandler:nil withTag:0 withButtonIndex:0];
                                               }];

      // print button
      UIAlertAction *actionPrint = [UIAlertAction
                                                      actionWithTitle:NSLocalizedString(@"IDS_LABEL_PRINT", nil)
                                                      style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

                                                          //action handler
                                                          [self actionHandler:nil withTag:kAttachmentActionSheetTag withButtonIndex:0];         
                                             }];

    // Create action sheet
     UIAlertController *alertController = [UIAlertController
                                                      alertControllerWithTitle:nil message:nil
                                                      preferredStyle:UIAlertControllerStyleActionSheet];

[alertController addAction:actionCancel];
[alertController addAction:actionPrint];

     // show aciton sheet
     [self  presentViewController:alertController animated:YES
                                 completion:nil] ;
mmccomb

在iPad上,警报将使用新的UIPopoverPresentationController显示为弹出窗口,它要求您使用以下三个属性之一为弹出窗口的显示指定锚点:

为了指定锚点,您将需要获取对UIAlertController的UIPopoverPresentationController的引用,并按如下所示设置属性之一:

alertController.popoverPresentationController.sourceView = parentView;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Swift UIAlertController-> ActionSheet iPad iOS8崩溃

尝试打印Unicode字符时出现运行时异常

创建Blob时出现运行时异常

为什么在Android中使用Recycler View时出现运行时异常

为什么在创建SqlClient类型时出现缺少的方法异常运行时?

在 ubuntu 上安装 magento 2 时出现运行时异常

在 Android Studio 中使用 ListView 时出现运行时错误(空指针异常)

显示运行时权限对话框时发生异常

尝试在Android中创建倒数计时器时出现运行时异常和空指针异常

Proguard导致Android导航组件出现运行时异常

运行时出现Google.Apis.Http.ConfigurableMessageHandler异常

从 CLI 运行时出现 CakePHP 3 / Phinx 异常

运行代码时遇到运行时异常

运行 .jar 文件时的 JavaFX 运行时异常

运行时错误“13”:显示来自 JSON 数组的数据时出现类型不匹配错误

运行Go代码时出现运行时错误

运行“粘贴”时,出现VBA运行时错误438

如何显示Haxe编译为Javascript运行时异常?

聚合Java 8流中的运行时异常

运行时异常:执行doInBackground()时发生错误

Android在使用gestureImageView和ViewGroup时的运行时异常

使用layoutInflator Xamarin膨胀时的运行时异常?

为什么会出现这种使用泛型不会抛出运行时或编译时的异常?

在15-20秒内重新打开时,应用程序崩溃并出现运行时异常

SDWebimage运行时异常

JavaFX运行时异常

SQL运行时异常

运行时gradle异常

奇怪的运行时异常