美文网首页
UIAlertController在view上响应推出

UIAlertController在view上响应推出

作者: 优雅地小男子 | 来源:发表于2018-01-18 13:56 被阅读16次

[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertVC animated:YES completion:nil];

😆因为在view上找不到控制器,而UIAlertController继承与controller,所以如果要在当前view推出,需要用到当前窗口的跟控制器。

另外,补充一句,也可以用UIActionSheet来推出弹窗:
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:nil, nil];
[sheet showInView:self.view];

相关文章

网友评论

      本文标题:UIAlertController在view上响应推出

      本文链接:https://www.haomeiwen.com/subject/nsqwoxtx.html