UITabBarController 对触摸无响应
因此,我的应用程序中有这样的视图层次结构:
UIWindow
UIViewController
UITabBarController -> 4 UINavigationController
我知道 UITabBarController 被设计为应用程序中的最顶层视图,但是在我的情况下这是不可能的。然而,我遇到的问题是,大约 20 个较低像素无法响应触摸,因此 UITabBarController 无法正确触发选项卡更改。这发生在实际设备(iPad 和 iPhone 3G)上。
我的问题是,是否有任何明显的原因导致这种情况发生?我将像这样的 UITabBarController 作为子视图添加到我的 UIViewController 视图中:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:controller.view]; // Controller is the UITabBarController
}
我没有设置 UITabBarController 的委托。
So, I have this view hierarchy in my app:
UIWindow
UIViewController
UITabBarController -> 4 UINavigationController
I know that a UITabBarController is designed to be the topmost view in an app, however this isn't possible in my case. However, the problem that I have is that ~20 of the lower pixels aren't responsive for touches so that the UITabBarController doesn't trigger the tab changes correctly. This happens on an actual device (iPad and iPhone 3G).
My question is, are there any obvious reasons why this could happen? I add the UITabBarController like this as subview to my UIViewController view:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:controller.view]; // Controller is the UITabBarController
}
I didn't set the UITabBarController's delegate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UITabBarController 永远不应该嵌入到 UIViewController 中,因为当它从 UIViewController 继承时,它已经是一个;只是有额外的天赋。当前根 UIViewController 正在拦截所有触摸事件。
使 UITabBarController 的视图成为应用程序委托中 UIWindow 的子视图。
UITabBarController should never be embedded in a UIViewController because, as it descends from UIViewController, it already is one; just with extra flair. Currently the root UIViewController is intercepting all of your touch events.
Make the UITabBarController's view the subview of your UIWindow in the app delegate.