您的位置:首页 > 产品设计 > UI/UE

使用UIAlertController报错

2016-01-20 16:29 537 查看
if (IOS8) {
UIAlertController * deleAlert = [UIAlertController alertControllerWithTitle:nil message:@"是否删除?" preferredStyle:UIAlertControllerStyleAlert];
[self.view.window.rootViewController presentViewController:deleAlert animated:YES completion:nil];
UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

}];
UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleCancel handler:nil];
[deleAlert addAction:sureAction];
[deleAlert addAction:cancelAction];
}

[self.view.window.rootViewController presentViewController:deleAlert animated:YES completion:nil];
如果使用
[self presentViewController:deleAlert animated:YES completion:nil];

会报错:

Presenting view controllers on detached view controllers is discouraged
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: