无法在iOS 6中处理方向? [英] Unable to handle orientation in iOS 6?

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

问题描述

我正在使用

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

委托根据方向类型更改我的视图框架

delegate to change the frame of my view based on the orientation type

if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
    self.view.frame=CGRectMake(0,0,500,300);
}
else
{
    self.view.frame=CGRectMake(0,0,300,400);
}

如何在iOS 6中处理与

How to handle the same situation in iOS 6 as

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

已在iOS6中弃用。

has been deprecated in iOS6.

我使用以下代理来设置所有方向。

I am using the following delegate to set all the orientations.

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationAllMask;
}

但是,

-(BOOL)shouldAutoRotate
{
    return YES;

}

未被调用。如何处理这种情况?

is not getting invoked. How to handle this situation?

推荐答案

在AppDelegate中,我已将ViewController对象添加到窗口

In the AppDelegate, I have added the ViewController Object to window as

[self.window addSubView:viewControllerObj]

问题出在上面一行。方向将适用于iOS 5中的上述行,但在iOS中,为了使方向正常工作,更改上面的行

The problem was with the above line. Orientation will work properly with the above line in iOS 5 but in iOS, for orientation to work properly, change the above line with

[self。 window setRootViewController:viewControllerObj]

然后当方向改变时,app会旋转。

Then the app rotates when orientation changes.

这篇关于无法在iOS 6中处理方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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