我在我的项目中使用了下面的UIAlertController代码。
if([[[UIDevice currentDevice] systemVersion]floatValue] >= 8.0){
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Input Error"
message:@"Please enter a valid email."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okAction = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:okAction];
[self presentViewController:alert animated:YES completion:nil];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Input Error"
message:@"Please enter a valid email"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
}我收到以下警告消息:
Warning: Attempt to present <UIAlertController: 0x7f8da58df1f0> on <MBComplaintsViewController: 0x7f8da36454d0> which is already presenting (null)请指导我如何使用Objective C正确使用UIAlertController。
谢谢,阿宾·科西·切里扬
发布于 2015-11-15 19:34:53
我不知道你有什么问题,但你不应该那样做
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];无论如何,它都会在你的任何actions上被驳回。
https://stackoverflow.com/questions/33428718
复制相似问题