2011-11-30 32 views
0

我视图控制器(Passwordviewcontroller),我想用 “presentModalviewController” 显示Ipad的presentModalViewController在一个视图控制器

我有一个AppDeleage:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
    // Override point for customization after application launch. 
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease]; 
    self.window.rootViewController = self.viewController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

,这里是我的ViewController从中我想PasswordviewController到显示:

-ViewDidLoad 
{ 
    self.passwordView = [[PasswordView alloc]initWithNibName:@"PasswordView" bundle:nil]; 
    [passwordView setModalPresentationStyle:UIModalPresentationFullScreen]; 
    [self presentModalViewController:passwordView animated:YES]; 
} 

我试过一切,但它仍然不工作,有人有一个想法?

+0

这是你的代码的精确复制/粘贴? – phi

+0

该AppDelegate是确切的代码。 但ViewDidLoad有更多的事情要做,而不仅仅是显示modalViewController。 我的ViewController有一个视图,在该视图中是WebViews,TableViews和ImageViews。 你需要更多的信息,请问 – verklixt

+0

是否可以'ViewDidLoad'应该是'viewDidLoad'? – phi

回答

0

把它放在viewDidAppear而不是viewDidLoad。在viewDidLoad您的视图可能会被加载到内存中,但不一定要在屏幕上。另一方面,在viewDidAppear中,您的视图已准备好显示为正确插入窗口中,以便显示模态视图。

编辑:改变viewWillAppearviewDidAppear按照意见

+0

仍然没有工作,我疯了,因为2天Iam试图获得这项工作。 – verklixt

+0

只是为了确保你的密码视图被初始化,而不是'nil',并且你的'viewWillAppear'真的被调用。 –

+0

这是我的NSLog: PasswordView是否正确初始化您是否阅读我的评论,以艾琳? – verklixt

相关问题