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