在UIview上弹窗 或者在UIWindow弹窗
2018-11-13 本文已影响9人
咸鱼有只喵
- (void)presentAlert:(UIAlertController *)alert {
//创建一个新window
UIWindow *alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *viewController = [[UIViewController alloc] init];
alertWindow.rootViewController = viewController;
[alertWindow makeKeyAndVisible];
[alertWindow.rootViewController presentViewController:alert animated:YES completion:nil];
}
- (void)dismissAlert {
//将当前页的keyWindow切换回来
AppDelegate *appDelegate = (id)[UIApplication sharedApplication].delegate;
[appDelegate.window makeKeyAndVisible];
}