2016-11-08 7 views
0

フォアグラウンドアプリケーションに入るときにUIViewControllerを表示します。
そして私はapplicationWillEnterForegroundメソッドでこのコードを使用していますが、Objective C appDelegateアプリでは動作しません。あなたは何を数えるんアプリケーションのデリゲートiOS10のapplicationWillEnterForegroundメソッドでモーダルUIViewControllerを表示する方法Objective C

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

はappDelegate内部self' 'のですか? – NSNoob

+0

私はuiviewcontrollerでSELFを使用していました。作品があります。しかし、私はここでそれを処理する方法を知らない。 –

+0

UIViewControllerクラスでは、selfはViewControllerです。 'presentViewController'はUIViewController.hで定義されているメソッドなので、そこで動作します。 AppDelegateでは、selfはAppDelegateであり、 'presentViewController'というメソッドはありません。 – NSNoob

答えて

0
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]; 
+0

このコードをapplicationWillEnterForegroundメソッドに使用しましたが、動作しません。 –

+0

[self.window.rootViewController.navigationController presentViewController:vc animated:YES completion:nil];を1回試してください。 – Bucket

関連する問題