[[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];
网友评论