Objective c 防止我的iOS 8 iPad操作单将其驳回';父视图控制器?
我相信这是一个iOS8错误,但我不确定。我可以用一个简单的项目很容易地复制它 在iOS8上,我以表单的形式呈现viewcontroller,然后在该表单中显示actionsheetObjective c 防止我的iOS 8 iPad操作单将其驳回';父视图控制器?,objective-c,ipad,ios8,uiactionsheet,Objective C,Ipad,Ios8,Uiactionsheet,我相信这是一个iOS8错误,但我不确定。我可以用一个简单的项目很容易地复制它 在iOS8上,我以表单的形式呈现viewcontroller,然后在该表单中显示actionsheet - (IBAction)showActionSheet:(id)sender { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"How can I stop the m
- (IBAction)showActionSheet:(id)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"How can I stop the modal formsheet from being dismissed with the actionsheet?"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Destructive"
otherButtonTitles:@"Another Button",nil];
[actionSheet showInView:self.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// Confirmation message is specific to the filter applied
NSLog(@"clicked %d",buttonIndex);
}
当此操作表根据用户选择自动取消时,它也将取消显示它的viewcontroller。有趣的是,如果在操作表外点击,它将被取消,但不会带上viewcontroller
有办法解决这个问题吗?也许是一种在行动表外“假装”窃听的方法
下面是一个简单的测试项目,演示了该行为:这里是临时修复。在操作表委托方法中使用以下代码
[self.presentedViewController dismissViewControllerAnimated:NO completion:nil];
UIAlertView和UIActionSheet在iOS8中已被弃用。它们将替换为UIAlertController 对于更新现有代码,我发现有效的解决方法是替换委托方法的使用:
actionSheet:clickedButtonAtIndex:
actionSheet:didDismissWithButtonIndex:
使用委托方法:
actionSheet:clickedButtonAtIndex:
actionSheet:didDismissWithButtonIndex:
这将确保在尝试呈现另一个视图控制器之前解除警报控制器
我在任何地方都遇到了这个问题,因为我试图通过选择行动表来呈现模式。这是一个常见的范例,当选择一张带有行动表的照片来请求相机或照片时。使用didDismissWithButtonIndex:允许向后兼容iOS 7
向前看,你应该拥抱UIAlertController。以下是一些阅读材料: