设备旋转后的非活动区域
我不明白我的非常简单的设备旋转应用程序出了什么问题:
- 我使用界面生成器构建了我的视图。 (参见此处的屏幕截图)
- 我指定了
UIInterfaceOrientation UIInterfaceOrientationLandscapeRight ;在我的 info.plist 文件中。 - 我的根视图控制器中有一个 (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return YES;} 。
左侧区域(在捕获中以红色显示)大约 20 像素宽度,保持不活动状态(如果我点击该区域中的按钮,则不会添加任何内容)。事实上,全屏仅在纵向模式下处于活动状态,在横向右侧模式下,有一个 20 像素宽度的非活动区域,在横向左侧模式下,该非活动区域位于右侧,在纵向倒置模式下,该区域位于底部。
我阅读了很多有关 UIView 旋转的帖子和文档,但没有找到任何解决此问题的方法(我尝试使用 view.frame 和 view.bounds 但没有成功)。
有人有主意吗?
多谢。
问候。 塞巴斯蒂安.
I don't understand what's wrong in my very simple application with device rotation :
- I built my view with interface builder. (See screen capture here)
- I specified <key>UIInterfaceOrientation</key><string>UIInterfaceOrientationLandscapeRight</string> in my info.plist file.
- I had a (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return YES;} in my root view controller.
The area on the left (shown in red on the capture), around 20 pixel width, keeps inactive (nothing append if I hit a button in this area). In fact the full screen is active only in portrait mode, in landscape right mode there is this 20 pixels width inactive area, in landscape left mode this inactive area is on the right, in portrait upside down mode this area is on the bottom.
I read lots of posts and documentation about UIView rotation, but I did not find anything to solve this problem (I tried to play with view.frame and view.bounds without any success).
Anybody has an idea ?
Thanks a lot.
Regards.
Sébastien.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的视图之一可能未正确自动调整大小。
旋转后,它仍然具有旧的边界,例如 320 x 460。由于视图通常不会剪切其包含的视图,因此您看不到差异。
另一方面,事件仅传递到包含在其超级视图边界中的视图。
One of your views is probably not autoresized correctly.
After rotation, it still has its old bounds of, for example, 320 x 460. Since views normally don't clip their contained views you don't see a difference.
Events on the other hand are only delivered to views that are contained in their superviews bounds.