iPhone UITabBarController - 难以单击选项卡项目

发布于 2024-10-21 19:49:56 字数 1054 浏览 1 评论 0原文

我的使用 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 技术交流群。

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

发布评论

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

评论(1

微凉 2024-10-28 19:49:56

我想通了。我正在使用:

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

这一定是切断了我的视图的可点击区域,并以某种方式切断了标签栏。我将其更改为:

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

它解决了我的问题。

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.

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