创建一个UIViewController
,将其view
添加到需要显示UIAlertController
的view
上,然后用UIViewController
显示
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"设置别名不得超过三个字" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:confirmAction];
//创建用于显示alertController的UIViewController
UIViewController *alertVC = [[UIViewController alloc]init];
[self addSubview:alertVC.view];
[alertVC presentViewController:alertController animated:YES completion:^{
//移除用于显示alertController的UIViewController
[alertVC.view removeFromSuperview];
}];
网友评论