简体   繁体   中英

iPhone UITabBarController - Hard to click tab items

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM