简体   繁体   English

设备旋转后的无效区域

[英]Inactive area after device rotation

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. 我在info.plist文件中指定了<key> UIInterfaceOrientation </ key> <string> UIInterfaceOrientationLandscapeRight </ string>。
  • I had a (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return YES;} in my root view controller. 我在根视图控制器中有一个(BOOL)应该AutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {返回YES;}

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). 左侧区域(捕获中以红色显示)约20像素宽度,处于不活动状态(如果我按了该区域中的任何按钮,则不会添加任何内容)。 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. 实际上,全屏仅在纵向模式下是活动的,在横向右模式下有20像素宽度的非活动区域,在横向左模式下此非活动区域在右侧,在纵向倒置模式下此区域在底部。

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). 我阅读了许多有关UIView旋转的文章和文档,但没有找到任何解决此问题的方法(我尝试使用view.frame和view.bounds都没有成功)。

Anybody has an idea ? 有人有主意吗?

Thanks a lot. 非常感谢。

Regards. 问候。 Sébastien. 塞巴斯蒂安。

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. 旋转后,它仍具有其旧边界,例如320 x460。由于视图通常不会剪切其包含的视图,因此您不会看到任何区别。

Events on the other hand are only delivered to views that are contained in their superviews bounds. 另一方面,事件仅传递给包含在其超级视图范围内的视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM