0

当我使用此代码时:

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

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:    (NSTimeInterval)duration {

  if ((toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) || toInterfaceOrientation==UIInterfaceOrientationLandscapeRight ) {
    LeftLVC* vc = [[LeftLVC alloc] initWithNibName:@"LeftLVC" bundle:nil];      
    [self.navigationController pushViewController:vc animated:YES];     
  }
}

子视图旋转。在我的项目中,子视图必须保持固定的肖像。

4

1 回答 1

0

shouldAutorotateToInterfaceOrientation:用于指定支持的方向。如果您只想支持纵向模式,那么:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);  
}

上述方法在 iOS 6.0 中已弃用。改写supportedInterfaceOrientationsandpreferredInterfaceOrientationForPresentation方法。有关详细信息,请阅读Apple 文档

willRotateToInterfaceOrientation:duration:在用户界面开始旋转之前发送到视图控制器。在这里,当您将方向从横向移动到纵向时,将调用此方法。

于 2012-10-08T11:19:21.420 回答