Objective c 双击使用UIAlertController显示的外部操作表弹出窗口,返回ios8 xcode 6 beta 5中的父视图

Objective c 双击使用UIAlertController显示的外部操作表弹出窗口,返回ios8 xcode 6 beta 5中的父视图,objective-c,ios8,xcode6-beta5,Objective C,Ios8,Xcode6 Beta5,我有一个行动表,我正在ios8(xcode 6 beta 5)中使用UIAlertcontroller演示。 我使用UIAlertcontroller是因为UIActionsheet(在iOS 8中不推荐使用)在iOS 8中无法正常工作,单击actionsheet中的任何选项会将我带回父视图。 现在,我在UIAlertcontroller中也面临一个问题,双击操作表弹出框外的按钮将我带回到上一个父视图。 以下是我的代码片段: UIAlertController *actionSheetIos8;

我有一个行动表,我正在ios8(xcode 6 beta 5)中使用UIAlertcontroller演示。 我使用UIAlertcontroller是因为UIActionsheet(在iOS 8中不推荐使用)在iOS 8中无法正常工作,单击actionsheet中的任何选项会将我带回父视图。 现在,我在UIAlertcontroller中也面临一个问题,双击操作表弹出框外的按钮将我带回到上一个父视图。 以下是我的代码片段:

UIAlertController *actionSheetIos8;

actionSheetIos8 = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

NSArray *buttonsArray = [self returnMoreArray];
int startY = 10;
for (int i = 0; i < [buttonsArray count]; i++) {

    UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:[buttonsArray objectAtIndex:i] style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        NSString *newStr = [buttonsArray objectAtIndex:i];
        newStr = [[newStr lowercaseString] stringByReplacingOccurrencesOfString:@" " withString:@"_"];
    }];
    [actionSheetIos8 addAction:defaultAction];        
}
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}];

[actionSheetIos8 setModalPresentationStyle:UIModalPresentationPopover];
UIPopoverPresentationController *popPresenter = [actionSheetIos8
                                                 popoverPresentationController];
popPresenter.sourceView = sender;
popPresenter.sourceRect = [sender frame];
dispatch_async(dispatch_get_main_queue(), ^ {
    [self presentViewController:actionSheetIos8 animated:YES completion:nil];
});
UIAlertController*actionSheetIos8;
actionSheetIos8=[UIAlertController alertControllerWithTitle:nil消息:nil首选样式:UIAlertControllerStyleActionSheet];
NSArray*按钮NSArray=[self returnMoreArray];
int startY=10;
对于(int i=0;i<[按钮阵列计数];i++){
UIAlertAction*defaultAction=[UIAlertAction actionWithTitle:[按钮阵列对象索引:i]样式:UIAlertActionStyleDefault处理程序:^(UIAlertAction*action){
NSString*newStr=[buttonsArray对象索引:i];
newStr=[[newStr lowercasesetring]stringByReplacingOccurrencesOfString:@“with string:@”u“];
}];
[actionSheetIos8 addAction:defaultAction];
}
UIAlertAction*cancelAction=[UIAlertAction actionWithTitle:@“取消”样式:UIAlertActionStyleCancel处理程序:^(UIAlertAction*action){
}];
[actionSheetIos8 setModalPresentationStyle:UIModalPresentationPopover];
UIPopoverPresentationController*popPresenter=[actionSheetIos8
popoverPresentationController];
popPresenter.sourceView=发送方;
popPresenter.sourceRect=[sender frame];
dispatch\u async(dispatch\u get\u main\u queue(),^{
[self-presentViewController:actionSheetIos8动画:是完成:无];
});

在我的popover presentation controller场景中,以下解决方案适用于我;我怀疑你的处境也有同样的问题:

  • UIPopoverPresentationController
    上设置代理(符合
    UIPopoverPresentationController
    协议)
  • 实现委托方法
    popoperpresentationcontrollersoulddismisspover:
  • 例如:

    /**
     The presence of this delegate callback inhibits the popover presentation controller
     from mistakenly calling 'dismissViewControllerAnimated:completion:' on us twice.
     */
    - (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController;
    {
        NSLog(@"delegate method called asking permission to dismiss popover");
        return YES;
    }
    
    下面是更多的上下文,我正在使用呈现的控制器和委托设置我的popover呈现控制器:

    // Set modal presentation style and issue the presentViewController:animated:completion:
    // call before retrieving popover presentation controller created for us, as suggested
    // in the API documentation that is more recent than the sample code from the
    // WWDC2014 slides in Session 228:
    presentedController.modalPresentationStyle = UIModalPresentationPopover;
    [self presentViewController:presentedController animated:YES completion:nil];
    
    // Now we can retrieve the popover presentation controller and configure it:
    UIPopoverPresentationController *popPC = presentedController.popoverPresentationController;
    popPC.permittedArrowDirections = UIPopoverArrowDirectionAny;
    CGRect popoverRect = cell.infoButton.bounds; // Assume 'cell' exists; it's an object of mine with an 'infoButton' view.
    popPC.sourceView = cell.infoButton; // has to be provided along with sourceRect
    popPC.sourceRect = popoverRect;  // has to be provided along with sourceView
    popPC.delegate = self; // or whomever you set to be your popover presentation controller delegate.
    

    我只是在使用popover演示控制器时遇到了同样的问题;在popover外双击会产生这种意想不到的(不受欢迎的)副作用。现在正在寻找解决方案……这个解决方案对我使用Xcode 6.0.1(6A317)很有效。rdar://18481560 我的雷达被标记为被苹果欺骗,所以我确信其他人都在大量报道这一点,并且在不久的将来会有一个适当的修复。