旋转后视图和按钮对触摸无响应

发布于 2024-09-26 08:40:33 字数 427 浏览 0 评论 0原文

我正在针对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你丑哭了我 2024-10-03 08:40:33

我已经解决了我遇到的问题..我基本上需要做[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 as self.view.frame and both were equal to (x=0,y=0,width=320,height=480). I then rotated self.view by M_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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文