根 UIViewController 方向景观,子视图中的触摸很奇怪
我正在制作一个仅横向的应用程序。因此,我的根 UIViewController 设置为横向(我拥有的所有 xib 文件都是横向)。
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
当我尝试触摸其中一个子视图中的按钮时,它没有收到触摸。如果我删除上面显示的覆盖,按钮会被触摸,但子视图会以纵向显示。
我应该如何解决这个问题?
谢谢&最好的问候,
大卫
I'm making an application which will be landscape only. Therefore, my root UIViewController is set to be landscape (all xib files I have are landscape orientation).
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
When I try to touch a button in one of the subviews, it does not receive a touch. If I remove the override shown above, the buttons get the touches, but the subview is shown in portrait orientation.
How should I work around this problem?
Thanks & Best Regards,
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除此之外,您必须在 info.plist 文件中设置支持的方向。
它位于“支持的界面方向”下,带有键“UISupportedInterfaceOrientations”。删除列表中的纵向方向。
Aside from that, you have to set the supported orientations in your info.plist file.
Its under "Supported interface orientations", with key "UISupportedInterfaceOrientations". Remove the portrait orientations in the list.