开发者

iPhone UITabBarController - Hard to click tab items

开发者 https://www.devze.com 2023-02-16 16:31 出处:网络
I\'m having a really strange issue with my application that uses the UIT开发者_运维知识库abBarController.

I'm having a really strange issue with my application that uses the UIT开发者_运维知识库abBarController.

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?


I figured it out. I was using:

CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
self.window = [[UIWindow alloc] initWithFrame:screenRect];

This must have been cutting off the clickable area of my views and slicing off the tab bar somehow. I changed it to:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

And it fixed my problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消