在AppDelegate中使用UIAlertController提示框

在AppDelegate中使用UIAlertController提示框

关于AppDelegate.m中无法使用UIAlertController
不喜欢UIAlertController,也可以自定义的。


    //初始化UIAlertController
    UIAlertController *alertCtl = [UIAlertController alertControllerWithTitle:@"提示" message:@"AppDelegate中" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *SureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        NSLog(@"确定点击了");
     
       }];
    UIAlertAction *CancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        NSLog(@"取消点击了");
        
    }];
    
    [alertCtl addAction:SureAction];
    [alertCtl addAction:CancelAction];
    
    //初始化UIWindows
    UIWindow *newWindow= [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    newWindow.rootViewController = [[UIViewController alloc]init];
    newWindow.windowLevel = UIWindowLevelAlert + 1;
    [newWindow makeKeyAndVisible];
    [newWindow.rootViewController presentViewController:alertCtl animated:YES completion:nil];
    


如果文章帮到您,喜欢点个赞,谢谢您。
文章内容出错,记得留言,感激不尽。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,552评论 25 708
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,255评论 4 61
  • 1、从这次课程中,你学到了什么?对你有哪些启发? (1)定位是重要的,但不是完美的、万能的; (2)定位需要结合市...
    魏旻阅读 199评论 0 1
  • 忽然明白,根本无需对未来和曾经做无谓的设想与缅怀,因为你决定朝前走的那一刻,过去就都与你无关。 ...
    浩浩vv阅读 415评论 0 0
  • 我想 在有鸟的地方 你也在哼着那动听的歌谣 我想 在有风的地方 你也在寻找那快乐的方向 我想 我想 在神圣的广场 ...
    黑曼巴时代阅读 189评论 2 2