- 在遇到某些情况时需要提示用户某些信息并执行某些修正动作,这时要用到警告视图,而在iOS9的时候UIAlertView已经被废弃了,取而代之的时UIAlertController。 直接贴代码:
//创建并初始化警告视图控制器 UIAlertController\* alertController = [UIAlertController alertControllerWithTitle:@"这里是标题" message:@"这里是提示信息" preferredStyle:UIAlertControllerStyleAlert]; //创建并初始化action UIAlertAction\* yesAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction\* _Nonnull action){ //do something.. }]; [alertController addAction: yesAction]; [self presentViewController: alertController animated:YES completion:nil];
网友评论