首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIAlertController警告消息

UIAlertController警告消息
EN

Stack Overflow用户
提问于 2015-10-30 12:34:14
回答 1查看 408关注 0票数 0

我在我的项目中使用了下面的UIAlertController代码。

代码语言:javascript
复制
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];
        }

我收到以下警告消息:

代码语言:javascript
复制
Warning: Attempt to present <UIAlertController: 0x7f8da58df1f0>  on <MBComplaintsViewController: 0x7f8da36454d0> which is already presenting (null)

请指导我如何使用Objective C正确使用UIAlertController。

谢谢,阿宾·科西·切里扬

EN

回答 1

Stack Overflow用户

发布于 2015-11-15 19:34:53

我不知道你有什么问题,但你不应该那样做

代码语言:javascript
复制
handler:^(UIAlertAction * action)
                                       {
                                           [alert dismissViewControllerAnimated:YES completion:nil];

                                       }];

无论如何,它都会在你的任何actions上被驳回。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33428718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档