简体   繁体   English

如何在应用程序委托iOS10目标C中的applicationWillEnterForeground方法中以模态呈现UIViewController

[英]How to present modally UIViewController in applicationWillEnterForeground method in app delegate iOS10 Objective C

I wanna present a UIViewController when come into foreground app. 当我进入前台应用程序时,我想展示一个UIViewController。
And i am using this code in applicationWillEnterForeground method in Objective C appDelegate app , but it does not works for me. 我在Objective C appDelegate应用程序的applicationWillEnterForeground方法中使用此代码,但对我不起作用。

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PasscodeViewController *vc = [sb instantiateViewControllerWithIdentifier:@"passcodeVCID"];
[self presentViewController:vc animated:YES completion:nil];
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PasscodeViewController *vc = [sb instantiateViewControllerWithIdentifier:@"passcodeVCID"];

// Need to present with rootviewcontroller

[self.window.rootViewController presentViewController:vc animated:YES completion:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM