在UIview上弹窗 或者在UIWindow弹窗
作者:
咸鱼有只喵 | 来源:发表于
2018-11-13 11:38 被阅读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];
}
本文标题:在UIview上弹窗 或者在UIWindow弹窗
本文链接:https://www.haomeiwen.com/subject/zpbkfqtx.html
网友评论