创建一个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];
}];









网友评论