方向在ios 5中不起作用,它在ios 6中工作 [英] orientation is not working in ios 5 and it is working in ios 6

查看:95
本文介绍了方向在ios 5中不起作用,它在ios 6中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的tabbar控制器应用程序中我有很多视图。所以我分类我的tabbar控制器就像这样。

in my tabbar controller application i have many views. so i sub classed my tabbar controller like this.

   -(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);


}

并且在我的视图控制器中

and in my view controller also

 - (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中工作。
谢谢。

my problem is orientation is working in ios 6 and not working in ios 5. thank you.

推荐答案

你应该在每个标签栏页面写这个函数

You should write this function in every tab bar page

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation          {

return YES;

}

//仅在需要时使用

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

//your view changing code

}

这篇关于方向在ios 5中不起作用,它在ios 6中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆