简体   繁体   English

在iPhone SDK中显示UIPickerView时隐藏UITabBar

[英]Hiding UITabBar when displaying UIPickerView in iPhone SDK

I've got a view when I want to use UIPickerView but my application supports also UITabBar. 当我想使用UIPickerView但我的应用程序也支持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. 我想在键盘弹出的同一位置显示UIPickerView,但问题是当我这样做时,标签栏按钮位于拾取器上方,只有一半是显示的。 Is is possible to temporary disable tab bar before I draw a picker and restore it when picker will disappear? 在我绘制选择器之前是否可以临时禁用标签栏并在选择器消失时恢复它?

Can you show us how you're displaying the UIPickerView ? 你能告诉我们你是如何显示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: 在这种情况下,尝试将UIPickerView作为子视图添加到窗口,而不是视图控制器的视图:

[[[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. 一个可能的警告是,如果在挑选视图到位时需要随时显示键盘,键盘将显示在挑选视图上方,隐藏它直到键盘再次被解除。

What if you called 如果你打电话怎么办?

myTabBarController.tabBar.hidden = YES;

before showing this picker view? 在显示此选择器视图之前?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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