2014-09-03 2 views
2

время выполнения исключение наступает время, когда я показать UIAlertController (ActionSheet) в iOS8 Beta5 + Xcode6.время выполнения Исключение наступает время, когда шоу UIAlertController (actionsheet) iOS8

Эта ошибка происходит только в iPad Устройства.

Я получаю исключение при использовании UIAlertController.

* Нагрузочного приложение из-за неперехваченное исключение 'NSGenericException', причина: ': должен иметь не всухую SourceView или barButtonItem установить до появления презентации UIPopoverPresentationController ( 0x15794370> < _UIAlertControllerActionSheetRegularPresentationController).

Мой кода для отображения 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] ; 

ответ

5

На IPad предупреждение будет отображаться как пирог с использованием нового UIPopoverPresentationController, он требует, чтобы указать точку привязки для презентации пирога с использованием один из трех следующих свойств:

Для того, чтобы указать точку привязки, вам необходимо получить ссылку на UIPopoverPresentationController в UIAlertController и установить одно из свойств следующим образом:

alertController.popoverPresentationController.sourceView = parentView; 
+0

Thankyou mmcomb. Ты просто спас меня. – Sabareesh

+0

Вам не нужно 'sourceView' и' sourceRect', если у вас нет 'barButtonItem'? Обсуждение 'sourceRect' в документах:« Используйте это свойство вместе с свойством sourceView, чтобы указать местоположение привязки для popover ». –

Смежные вопросы