iPhone SDK中显示UIPickerView时隐藏UITabBar
当我想使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您能否向我们展示您如何显示
UIPickerView
?我假设您将其作为子视图添加到从选项卡栏显示的视图控制器中,并设置其框架,使其位置与键盘相同。在这种情况下,请尝试将 UIPickerView 作为子视图添加到窗口,而不是视图控制器的视图:
这应该将其显示在所有其他视图之上。
一个可能的警告是,如果在选择器视图就位时需要随时显示键盘,则键盘将显示在选择器视图上方,并将其隐藏,直到再次关闭键盘。
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: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.
如果您
调用
myTabBarController.tabBar.hidden = YES;
会怎样?在显示此选择器视图之前
What if you called
myTabBarController.tabBar.hidden = YES;
before showing this picker view?