iPhone SDK中显示UIPickerView时隐藏UITabBar

发布于 2024-08-21 03:47:55 字数 150 浏览 9 评论 0原文

当我想使用 UIPickerView 但我的应用程序也支持 UITabBar 时,我有一个视图。我想在键盘弹出的同一位置显示 UIPickerView,但问题是,当我这样做时,选项卡栏按钮位于选择器上方,并且只显示一半。在绘制选择器之前是否可以暂时禁用选项卡栏,并在选择器消失时恢复它?

I've got a view when I want to use UIPickerView but my application supports also UITabBar. I want to display UIPickerView in the same spot where keyboard pops up but the problem is that when I do that tab bar buttons are above picker and only half of it is beign displayed. Is is possible to temporary disable tab bar before I draw a picker and restore it when picker will disappear?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

远昼 2024-08-28 03:47:55

您能否向我们展示您如何显示 UIPickerView?我假设您将其作为子视图添加到从选项卡栏显示的视图控制器中,并设置其框架,使其位置与键盘相同。

在这种情况下,请尝试将 UIPickerView 作为子视图添加到窗口,而不是视图控制器的视图:

[[[UIApplication sharedApplication] keyWindow] addSubview:myPickerView];

这应该将其显示在所有其他视图之上。

一个可能的警告是,如果在选择器视图就位时需要随时显示键盘,则键盘将显示在选择器视图上方,并将其隐藏,直到再次关闭键盘。

Can you show us how you're displaying the UIPickerView? I'll assume you're adding it as a subview to a view controller that is shown from a tab bar, and setting its frame so that it is positioned the same as the keyboard.

In that case, try adding the UIPickerView as a subview to the window, rather than the view controller's view:

[[[UIApplication sharedApplication] keyWindow] addSubview:myPickerView];

This should show it above all other views.

One likely caveat is that if a keyboard needs to be shown at any time while your pickerview is in place, the keyboard will show above your pickerview, hiding it until the keyboard is dismissed again.

┊风居住的梦幻卍 2024-08-28 03:47:55

如果您

调用myTabBarController.tabBar.hidden = YES;会怎样?

在显示此选择器视图之前

What if you called

myTabBarController.tabBar.hidden = YES;

before showing this picker view?

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