问题
我遇到了 UIAlertController
的问题 . 这是一个iPad项目,我有两个类,比如第一和第二 .
我使用模态演示文稿呈现Second from First . 在第二课我有一个按钮,点击我正在显示UIActionSheet来执行一些动作 . 它工作得很好,除非用户快速点击按钮,第二课程被解雇 .
代码
First VC:
- (IBAction)showNext:(id)sender
{
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondVC"];
[self presentViewController:vc animated:YES completion:nil];
}
Second VC:
- (IBAction)showActionSheet:(UIButton *)sender
{
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[alertVC addAction:[UIAlertAction actionWithTitle:@"LogOut"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action)
{
}]];
[alertVC addAction:[UIAlertAction actionWithTitle:@"Update"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
}]];
[alertVC setModalPresentationStyle:UIModalPresentationPopover];
UIPopoverPresentationController *popPresenter = [alertVC popoverPresentationController];
popPresenter.sourceView = sender;
popPresenter.sourceRect = sender.bounds;
[self presentViewController:alertVC animated:YES completion:nil];
}
这两个类中没有其他代码 . 我不知道它为什么会发生,实际上它发生在我的一个客户端项目中,所以我用上面的代码创建了一个测试应用程序,它也导致了这个问题 .
屏幕截图
我尝试过的:
-
在Google上搜索了一下,没有出现任何问题
替代品:
-
如果我将Second class设置为
rootViewController
,那么问题就是't be there (But I can' t那样做,我需要来回导航) -
如果我在外面触摸时禁用了弹出式解雇,则可以避免此问题 . 但我需要这个工作流程 .
有人可以帮帮我吗?我现在完全迷失了,没有得到任何有用的信息 . 提前致谢 .
1 回答
我不知道是什么问题,但我修好了 . 我使用
popoverPresentationControllerShouldDismissPopover
并返回YES
.Eureka:
这是一次意外!我没有得到任何其他方法来解决这个问题,所以我认为会做第二种选择 . 写作的时候我不小心写了
YES
而不是NO
. 但它有效,我不知道它是如何工作的,这个问题的原因是什么 .