相关疑难解决方法(0)

iOS 6 ViewController正在旋转,但不应该

我希望我的几个应用程序视图控制器不在iOS 6.0中旋转.这就是我在iOS 6中进行旋转所做的事情:

1.)在应用程序中设置windows rootviewController:didFinishLaunchingWithOptions:

self.window.rootViewController = self.tabBarController;
Run Code Online (Sandbox Code Playgroud)

2.)在我的目标(在XCode中)中设置"支持的接口方向",以便我可以使用所有方向

3.)实现了新的iOS 6.0旋转功能

- (BOOL) shouldAutorotate {

    return YES;
}


-(NSUInteger)supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskAll;
}
Run Code Online (Sandbox Code Playgroud)

4.)由于某些原因,我将UINavigationController子类化并实现了这些新功能并使用了这个新的NavigationController而不是原始的.

到目前为止一切顺利,所有视图控制器现在都可以旋转到每个方向.现在我想要几个viewController不旋转,只留在肖像.但是当我在这样的特定视图控制器中设置新的旋转方法时,它仍然会旋转到每个方向:

- (BOOL) shouldAutorotate {

    return NO;
}


-(NSUInteger)supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

同样像上面那样设置navigationController的旋转功能不会改变任何东西.(所有视图控制器都可以旋转到每个方向)

我究竟做错了什么?

编辑:

设置首选的Interfaceorientation也不会改变任何内容:

- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {

    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller ios6 xcode4.5

8
推荐指数
1
解决办法
6509
查看次数

iOS 6在dismissModalViewController之后恢复方向

我有一个UITabBarViewController纵向模式,我modalViewController在那里推进景观.当我按下模态时,旋转会变为横向,但是当我将其关闭时,方向仍保留在横向中而不是恢复为纵向.

码:

a CustomUINavigationController为横向模式:

- (BOOL)shouldAutorotate
{
  return [[self.viewControllers lastObject] shouldAutorotate];
}

- (NSUInteger)supportedInterfaceOrientations
{
  return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
Run Code Online (Sandbox Code Playgroud)

uitabbarcontroller

- (BOOL)shouldAutorotate
{
  if ([self inModal]) {
    UINavigationController *nav = (UINavigationController *)self.modalViewController;
    return [[nav.viewControllers lastObject] shouldAutorotate];
  } else {
    return NO;
  }
}

-(NSUInteger)supportedInterfaceOrientations
{
  if ([self inModal]) {
    UINavigationController *nav = (UINavigationController *)self.modalViewController;
    return [[nav.viewControllers lastObject] supportedInterfaceOrientations];
  } else {
    return UIInterfaceOrientationPortrait;
  }    
}

- …
Run Code Online (Sandbox Code Playgroud)

ios ios6

3
推荐指数
1
解决办法
7995
查看次数

标签 统计

ios6 ×2

ios ×1

uiviewcontroller ×1

xcode4.5 ×1