0

我正在使用 ios SDK 5

我正在像这样从父视图控制器推送视图控制器

DetailsViewController *detailController = [[DetailsViewController alloc] initWithNibName:@"DetailsViewController" bundle:nil] ;
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
[self.navigationController pushViewController:detailController animated:YES];

因为我想以横向模式打开我的新控制器。我的父视图控制器处于 potrait 模式,所以我设置为

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

在我的子视图控制器中,我将其设置为

   - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
         return interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight;
    }

但是当我的子视图控制器打开时,它仍然会旋转到横向模式,但是像滚动视图和它的子视图这样的内部视图仍然处于 potrait 模式。我已经阅读了很多类似的问题并尝试了它们,但它们都不适合我。请指出正确的方向,以了解如何在 viewcontroller 中旋转所有视图

谢谢

4

1 回答 1

0

换个方法就好了

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     return interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}

经过,

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     return  UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
于 2012-12-11T07:01:59.783 回答