Trying to dismiss the presentation controller while transitioning already

来源:互联网 发布:turtlebot编程 编辑:程序博客网 时间:2024/05/18 01:18

iOS8开始使用UIAlertController
今天遇到一个问题,效果是展示一个alert 之后消失
在iOS8中崩溃
崩溃信息:

Trying to dismiss the presentation controller while transitioning already. (<_UIAlertControllerAlertPresentationController: 0x78feff20>)transitionViewForCurrentTransition is not set, presentation controller was dismissed during the presentation? (<_UIAlertControllerAlertPresentationController: 0x78feff20>)

这是写的代码

UIAlertController* vc = [UIAlertController alertControllerWithTitle:message message:nil preferredStyle:UIAlertControllerStyleAlert];[target presentViewController:vc animated:YES completion:^{    [vc dismissViewControllerAnimated:YES completion:NULL];}];

后来发现需要这样写问题解决

UIAlertController* vc = [UIAlertController alertControllerWithTitle:message message:nil preferredStyle:UIAlertControllerStyleAlert];    [target presentViewController:vc animated:YES completion:^{        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{            [vc dismissViewControllerAnimated:YES completion:NULL];        });    }];
1 0
原创粉丝点击