2012-03-19 43 views
0

變化如何調用方法調用方向上的viewDidLoad

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) || 
    (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

在viewDidLoad中。
第一個視圖不應該改變爲橫向,第二個視圖應該能夠改變爲橫向。但是,當我在第二個視圖中更改橫向並返回到第一個視圖時,第一個視圖將保持橫向直到我旋轉設備。

回答

0

您可以張貼手動通知:

[[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceOrientationDidChangeNotification object:nil]; 
+0

不起作用anyway.i從另一個room.UIViewController * C = [[UIViewController中的alloc] INIT]發現這; [self presentModalViewController:c animated:NO]; [self dismissModalViewControllerAnimated:NO]; [c release];它的工作原理是 。 – Albert 2012-03-20 02:27:44

+0

可能是因爲你從'viewDidLoad'調用它,當你彈出你的第二個視圖時,它不會被再次調用。如果你從'viewDidAppear'調用它,它應該工作。我認爲這是一個比呈現和解散視圖控制器更好的解決方案。但是,如果您喜歡您的解決方案,請將其作爲答案並接受。 – Saphrosit 2012-03-20 13:34:43