我在旋轉設備時嘗試更改視圖佈局時遇到了一些麻煩,我的主視圖叫做OverviewViewController,它包含2個視圖,當設備處於特定方向時它將隱藏/顯示。在子視圖中的shouldAutorotateToInterfaceOrientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// do some layout stuff
NSLog(@"OverviewViewController shouldAutorotateToInterfaceOrientation");
return YES;
}
每當我轉動我的設備執行該方法兩次,但在任何子視圖它從來不叫,例如;
// In OverviewViewController
_landscapeView = [[LandscapeOverviewViewController alloc] initWithNibName:nil bundle:nil];
[self.view addSubview:_landscapeView.view];
// In LandscapeOverviewViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSLog(@"LandscapeOverviewViewController: shouldAutorateToInterfaceOrientation");
// Only change orientation when it's landscape
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) return YES;
return NO;
}
是否有一個子視圖不響應設備方向的原因?該方法從來沒有在那裏調用。
模態呈現這些視圖控制器,與此代碼,你說,在旋轉時,overviewViewController調用shouldAutorotateToInterfaceOrientation方法,但LandscapeOverviewViewController犯規通話shouldAutorotateToInterfaceOrientation? – 2012-07-30 03:29:18
http://developer.apple.com/library/ios/#qa/qa1688/_index.html – Luke 2012-07-30 03:33:23
@calvinBhai這正是我的意思,是的。 – 2012-07-30 03:36:22