Search code examples
iphoneobjective-ccocoa-touchuipickerviewuitabbar

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. 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?


Solution

  • 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.