1

在我的标签栏控制器应用程序中,我有很多视图。所以我像这样对我的标签栏控制器进行了分类。

   -(BOOL)shouldAutorotate
 {

   return [[self.viewControllers lastObject] shouldAutorotate];
  }

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

  - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
   {
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
   }

  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation            { 
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return (UIInterfaceOrientationMaskAll);


}

在我的视图控制器中

 - (BOOL)shouldAutorotate
{
return YES;
 }

 - (NSUInteger)supportedInterfaceOrientations
{
   return (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight);

//OR return (UIInterfaceOrientationMaskAll);
 }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation          {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return (UIInterfaceOrientationMaskAll);



  }
    - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
 {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
    toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{

}
else
{

}
   }

我的问题是方向在 ios 6 中有效,而在 ios 5 中无效。谢谢。

4

2 回答 2

2

您应该在每个标签栏页面中编写此功能

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation          {

return YES;

}

//仅在需要时使用

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

//your view changing code

}
于 2013-07-05T09:50:22.723 回答
1

将此代码添加到您的视图控制器中,适用于 ios 5

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return  UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait;

}
于 2013-07-05T09:47:23.943 回答