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
本文介绍如何在iOS8环境下使用UIAlertController创建一个简单的删除确认对话框,并展示了正确的呈现方式及常见错误避免。
5677

被折叠的 条评论
为什么被折叠?



