旋转后视图和按钮对触摸无响应
我正在针对 iOS 3.0 进行编码,并且正在尝试向我的应用程序添加旋转(横向)支持。
关于轮换的一切都很简单。但是,从纵向旋转到横向模式后,屏幕的右三分之一 (480-320) 对所有事件(触摸、拖动等)都没有响应。我已经验证关键窗口正在接收事件,但这些事件没有传递到屏幕右侧(横向)的按钮和 UIView。
我正在使用 NSNotificationCenter 接收方向更改事件(并且不使用自动旋转标志)。
我确实看到:链接文本 但这对我的案子没有多大帮助。
卡住。需要帮助。谢谢。
I am coding against iOS 3.0 and I am trying to add rotation (landscape) support to my app.
Everything about the rotation was easy enough. However, after rotation to landscape mode from portrait, the right-third of the screen (480-320) is unresponsive to all events (touches, drag, etc.). I've verified that the key window is receiving the events but those events are not being passed to the buttons and UIViews on the right (in landscape) side of the screen.
I am using NSNotificationCenter to receive orientation changed events (and not using autorotate flag).
I did see: link text but that wasn't very helpful to my case.
Stuck. Need help. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经解决了我遇到的问题..我基本上需要做
[self.navigationController.view setNeedsLayout]
。我理解这一点的方式(可能不正确的是, self.navigationController.view.frame 与 self.view.frame 相同,并且两者都等于 (x=0, y=0,width=320,height=480)。然后我将
self.view
旋转了M_PI/2
并在选择 self.view 上进行了一些帧操作。子视图使所有内容都正确地进行动画/位置/缩放,效果很好,但导航控制器不愿意承认 320 右侧 self.view 部分的触摸事件。本质上,如果这个
self .navigationController.view.clipsToBounds 是正确的,它甚至可能没有显示 self.view 的那部分。
无论如何,在导航控制器的视图上设置 setNeedsLayout 解决了这个问题。
I've fixed the problem I was having .. I basically needed to do
[self.navigationController.view setNeedsLayout]
.The way I understand this (which maybe incorrect is that
self.navigationController.view.frame
was same asself.view.frame
and both were equal to (x=0,y=0,width=320,height=480). I then rotatedself.view
byM_PI/2
and did a number of frame manipulation on select self.view.subviews to get everything to animate/position/scale correctly.That worked out okay but the navigation controller was not willing to acknowledge touch events to parts of self.view there were to the right of 320. In essence, if this
self.navigationController.view.clipsToBounds
were true, it might not even have shown that part of self.view.Anyway, setting setNeedsLayout on the navigation controller's view resolved the issue. I hope this helps someone else.