繁体   English   中英

UITableViewController subView旋转

[英]UITableViewController subView rotation

我是Stackoverflow和Objective-C编程的新手。 我已经搜索了下面描述的问题,但是找不到有效的解决方案。

我的应用程序是一个简单的脱机浏览应用程序,具有导航结构。 在appDelegate中,我通过以下方式之一加载RootViewController(UITableViewController):

解决方案A

   [window addSubview:navigationController.view];
   [window makeKeyAndVisible];
   return YES;

解决方案B

   RootViewController* rootviewcontroller = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];    
   navigationController = [[UINavigationController alloc] initWithRootViewController:rootviewcontroller];

rootViewController只是推送一些视图,即

 TipAndTrickViewController *mTipAndTrick = [[TipAndTrickViewController alloc]initWithNibName:@"TipAndTrickViewController" bundle:nil]; 
 [self.navigationController pushViewController:mTipAndTrick animated:YES];

在更深的视图中,我呈现了一个详细的modalView(UIViewController)。 我想要的是仅在最后一个视图中启用自动旋转。 对于所有先前的想法,肖像取向是期望的。 最后一个视图以正确的方式实现:

应该AutorotateToInterfaceOrientation:interfaceOrientation

应该自动旋转

willRotateToInterfaceOrientation:toInterfaceOrientation持续时间:持续时间

willAnimateRotationToInterfaceOrientation:interfaceOrientation持续时间:持续时间

覆写

应该自动旋转

应该AutorotateToInterfaceOrientation:interfaceOrientation

使他们在rootViewController中返回NO / YES,并使用所需的方式设置允许的方向,使用

支持的接口方向

(在rootViewCOntroller和最后一个视图中),我得到的结果是:

  • 如果我使用解决方案A,则所有视图都不会旋转。
  • 如果我使用解决方案B,则所有视图都会旋转。

我做错了什么? 预先感谢您的帮助

将它们添加到您的viewController中,让我知道它是否有效。

// iOS5旋转

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

// iOS6旋转

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

- (BOOL)shouldAutorotate
{
    return YES;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM