UIViewController - addSubview工作但不presentModalViewController
问题描述:
我有一个UIViewController
,我提出了一个GTLMOAuth2ViewControllerTouch
(谷歌身份验证),这也是一个视图控制器。我介绍使用“presentModalViewController”。然后,验证成功后,GTLMOAuth2ViewController
自行解散。接下来,我尝试提出了另一个UIViewController
,在这一点,如果我说:UIViewController - addSubview工作但不presentModalViewController
[self presentModalViewController:anotherViewController animated:YES];
它不工作,也没有视图控制器节目。但是,如果我把:
[self.view addSubview:anotherViewController.view];
它的工作,除了在屏幕上视图似乎太低。
为什么我不能使用presentModalViewController
?
答
我认为这取决于您调用presentModalViewController的时间。我最近在类似情况下的经验是,在调用viewDidAppear之前,不能调用presentModalViewController。如果你这样做,什么都不会发生。但你可以在loadView或viewDidLoad中调用addSubview,viewWillAppear并且工作得很好。
我无法回答“为什么”它是这样的,但这是我的观察。希望这可以帮助!
希望它可以帮助你http://stackoverflow.com/questions/4221988/self-navigationcontroller-pushviewcontroller-wont-work – Allan 2012-09-13 07:33:41