how to get my UIWindow using UIApplication?

前端 未结 4 1893
半阙折子戏
半阙折子戏 2020-12-25 10:21

I have only one window and I tried

UIWindow* mWindow = [[UIApplication sharedApplication] keyWindow];

but this returned nil.

I also

4条回答
  •  一整个雨季
    2020-12-25 10:38

    If your main window is an outlet of your AppDelegate (which should be the case), you may simply use

    MyAppDelegate* myDelegate = (((MyAppDelegate*) [UIApplication sharedApplication].delegate));
    [myDelegate.window ...]
    

提交回复
热议问题