首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ios6旋转问题

ios6旋转问题
EN

Stack Overflow用户
提问于 2012-11-19 13:30:03
回答 4查看 200关注 0票数 0

我正在将我的应用程序转换为ios6,但我遇到了旋转问题。有人能告诉我旋转设备时需要调用哪些方法吗?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2012-11-20 13:24:46

代码语言:javascript
复制
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration 
{
    [self doLayoutForOrientation:toInterfaceOrientation]; 
}


- (void)doLayoutForOrientation:(UIInterfaceOrientation)orientation { 
if (UIInterfaceOrientationIsPortrait(orientation)) 
{
//set the frames here
}
else 
{
//set the frames here
} 
}

这些是ios 6中的新方法,您可以根据方向设置帧。希望能对你有所帮助。

票数 0
EN

Stack Overflow用户

发布于 2012-11-19 14:07:37

- (BOOL) shouldAutorotate -(NSUInteger)supportedInterfaceOrientations

这些是添加到iOS 6中的新功能。

票数 0
EN

Stack Overflow用户

发布于 2012-11-19 14:48:59

代码语言:javascript
复制
 -(NSUInteger)supportedInterfaceOrientations

{
    return UIInterfaceOrientationMaskAll;
}

-(void)viewWillLayoutSubviews
{
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown)
    {
     //set the frames here
    }
    else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
    {
      //set the frames here
    }
}

最好这样做,当你每次改变设备的方向时,上面的方法都会被调用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13448192

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档