2016-11-08 1 views
0

포 그라운드 응용 프로그램에 들어올 때 UIViewController를 표시하려고합니다.
그리고이 코드는 applicationWillEnterForeground Objective C appDelegate 앱에서 사용하고 있지만 나에게는 적합하지 않습니다. 당신이 무엇을 이해 할수 않습니다응용 프로그램 대리인 iOS10의 applicationWillEnterForeground 메서드에서 모달 UIViewController를 표시하는 방법 ObjectiveC

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 : 예 완료 : 없음]; – Bucket

관련 문제