我在用- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
委托(delegate)根据方向类型更改我的 View 框架
IE。,
if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
self.view.frame=CGRectMake(0,0,500,300);
}
else
{
self.view.frame=CGRectMake(0,0,300,400);
}
如何在 iOS 6 中处理与
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
在 iOS6 中已被弃用。
我正在使用以下委托(delegate)来设置所有方向。
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationAllMask;
}
但,
-(BOOL)shouldAutoRotate
{
return YES;
}
没有被调用。如何处理这种情况?
最佳答案
在 AppDelegate 中,我已将 ViewController 对象添加到窗口中[self.window addSubView:viewControllerObj]
问题出在上面的行上。在 iOS 5 中,方向将与上述行正常工作,但在 iOS 中,要使方向正常工作,请将上述行更改为[self.window setRootViewController:viewControllerObj]
然后当方向改变时应用程序会旋转。
关于ipad - 无法在 iOS 6 中处理方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12519693/