2011-11-30 31 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

相關問題