찾다

 >  Q&A  >  본문

ios - 如何在Appdelegate中通过获取keyWindow来present一个UIViewAlertViewController

1.问题描述

我想要在- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions中弹出present出一个UIViewAlertViewController,效果就是在启动页的时候弹出更新提示,但是因为当前的这个window还没有成为keyWindow,所以在启动页消失后,层次图就会变成下面这样。

是否只能等首页出现弹出UIAlertViewController才能正确的在keyWindow上弹出?

2.代码

[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertControler animated:YES completion:^{
                
}];

也使用过

UIWindow *window = [UIApplication sharedApplication].delegate.window;
[window makeKeyAndVisible];
[window.rootViewController presentViewController:alertControler animated:YES completion:^{
                
}];

3.请教

1.怎么样才是正确的姿势。。。
2.是否是因为当前的keyWindow和启动图过后出现首页时的keyWindow不同。(我觉得是这个原因)

高洛峰高洛峰2887일 전281

모든 응답(4)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-04-17 17:53:47

    필요에 따라 엔트리 클래스가 아닌 스타트업 페이지에서 운영해야 합니다

    회신하다
    0
  • ringa_lee

    ringa_lee2017-04-17 17:53:47

    테스트해보고 주소를 인쇄하여 동일한지 확인해 보는 것은 어떨까요?

    회신하다
    0
  • 怪我咯

    怪我咯2017-04-17 17:53:47

    내비게이션으로 푸시는 안되나요?

    회신하다
    0
  • 巴扎黑

    巴扎黑2017-04-17 17:53:47

    키윈도우를 사용해야 하는 이유는 무엇인가요? 네비게이션 컨트롤러나 tabBarController는 사용할 수 없나요?

    회신하다
    0
  • 취소회신하다