iPhone UITabBarController - 难以单击选项卡项目
我的使用 UITabBarController 的应用程序遇到了一个非常奇怪的问题。
首先,我以编程方式创建选项卡栏,而不是使用 NIB,ala:
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity: 3];
UINavigationController *nav;
VisitViewController *viewVisit = [[VisitViewController alloc] initWithTabBar];
nav = [[UINavigationController alloc] initWithRootViewController: viewVisit];
[localControllersArray addObject:nav];
[nav release];
[viewVisit release];
// ... other tabs, same format as previous
tabBarController.viewControllers = localControllersArray;
[localControllersArray release];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
另一件事需要注意,是在我添加的每个视图控制器中,我调用“self.title = 'Tab Title';”设置标题文本。但我怀疑这是否重要。
无论如何,一切都运行并显示良好 - 我遇到的问题是,如果我单击选项卡图像的下半部分,则什么也不会发生。我必须单击 50% 标记上方才能获取选项卡项目以选择和更改选项卡。
如果您查看标签栏应用程序,就会发现水平中间有一种自然的渐变中断。基本上该线以下的任何内容,我都无法单击来切换选项卡。这真的很烦人,因为在设备上它会让你一遍又一遍地单击选项卡,直到超过该标记,并且感觉非常缓慢。在 Twitter 等其他选项卡应用程序上,它运行得很好。
有什么想法吗?
I'm having a really strange issue with my application that uses the UITabBarController.
First, I'm creating the tab bar programmatically and not using NIBs, ala:
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity: 3];
UINavigationController *nav;
VisitViewController *viewVisit = [[VisitViewController alloc] initWithTabBar];
nav = [[UINavigationController alloc] initWithRootViewController: viewVisit];
[localControllersArray addObject:nav];
[nav release];
[viewVisit release];
// ... other tabs, same format as previous
tabBarController.viewControllers = localControllersArray;
[localControllersArray release];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
One other thing to note, is that in each view controller I'm adding, I'm calling "self.title = 'Tab Title';" to set the title text. I doubt that matters though.
Anyway, everything runs and displays fine -- the problem I'm having is that if I click on the bottom half of the tab image nothing happens. I have to click above the 50% mark to get the tab item to select and change the tabs.
If you look at tab bar applications, there's sort of a natural gradient break right down the middle horizontally. Basically anything below that line, I can't click to switch tabs. It's really annoying because on a device it makes you click the tab over and over until you get above that mark, and it feels very sluggish. On other tab apps like Twitter it works perfectly.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了。我正在使用:
这一定是切断了我的视图的可点击区域,并以某种方式切断了标签栏。我将其更改为:
它解决了我的问题。
I figured it out. I was using:
This must have been cutting off the clickable area of my views and slicing off the tab bar somehow. I changed it to:
And it fixed my problem.