setOrientation问题 [英] setOrientation problem

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

问题描述

我有一个非常奇怪的方向问题。我在导航控制器下有一系列视图控制器。其中一个可以采取任何方向。当我离开方向时,我必须使用setOrientation。有趣的是旋转发生在转换发生到下一页时。除了单个案例之外,这通常不是问题 - 从UIDeviceOrientationPortraitUpsideDown到正常导致我所有顶级挂载的项目都会向上迁移大约八分之一。

I have a really strange orientation issue. I have a sequence of view controllers under a navigation controller. One of them can take any orientation. When I'm leaving the orientation I have to use setOrientation. The funny thing is the rotation takes place as the transition occurs to the next page. This isn't normally a problem except for a single case -- from UIDeviceOrientationPortraitUpsideDown to normal causes all my top mounted items to migrate up about an eighth of a page.

那里有三种方法我认为我可以解决它:

There are three ways I think I could fix it:


  1. 以某种方式将setOrientation与我的
    pushViewController调用分开(所以新视图不会不需要翻转)

  2. 将我的物品设置为
    以更好的方式锚定在设备顶部
    (我检查了它们似乎是)

  3. 重置
    ViewDidLoad方法元素的Y维度,但这似乎不对。

这是我将新视图推送到堆栈代码:

Here's my push the new view onto the stack code:

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait]; 

ResultSelect_ViewController *resultSelect = [[ResultSelect_ViewController alloc] initWithNibName:@"ResultSelect" bundle:nil];
[self.navigationController pushViewController:resultSelect animated:YES];

其他人觉得奇怪,模拟器不允许你测试颠倒到肖像行为?

Anybody else find it odd that the simulator doesn't allow you to test the upside down to portrait behavior?

推荐答案

从上下旋转到肖像时避免旋转错误的方法不是这样做的。相反,中途停止旋转两次(例如 UIDeviceOrientationLandscapeRight )。计时的问题不是使用睡眠而是实现 didRotateFromInterfaceOrientation 并在此时触发第二次旋转(或推送到下一个视图)。

The way to avoid the rotation bug when rotating from upside down to portrait is not to do it. Instead, rotate twice stopping halfway (say UIDeviceOrientationLandscapeRight). The question of timing is not to use sleep but instead implement didRotateFromInterfaceOrientation and fire the second rotation (or push to next view) at that point.

这篇关于setOrientation问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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