2

iOS8 Beta5+ Xcode6UIAlertController(ActionSheet)を表示すると、ランタイム例外が発生します。

このバグはiPadデバイスでのみ発生しています。

UIAlertController を使用すると、以下の例外が発生します。

*キャッチされない例外 'NSGenericException' が原因でアプリを終了しています。

次のようにアクションシートを表示するためのマイコード

     // 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] ;
4

1 に答える 1

5

iPad では、アラートは新しいUIPopoverPresentationControllerを使用してポップオーバーとして表示されます。次の 3 つのプロパティのいずれかを使用して、ポップオーバーの表示用のアンカー ポイントを指定する必要があります。

アンカー ポイントを指定するには、UIAlertController の UIPopoverPresentationController への参照を取得し、プロパティの 1 つを次のように設定する必要があります。

alertController.popoverPresentationController.sourceView = parentView;
于 2014-09-03T09:49:32.420 に答える