Search code examples
iosxcodeuipickerview

How to hide UIPickerView in interface builder?


When I edit the xib file, the UIPickerView occupy a very large space, kind of annoying, how can I hide it when I do not want to see it?


Solution

  • You can't "hide" it from Interface Builder, but there are two or maybe three things you can do to make it less distracting for you.

    1)

    Change the order in which it appears in your ViewController to be the highest (or actually the deepest), so it's behind everything else. Then all other controls or views you put over the Picker will be "on top" of the Picker.

    Here's what it looks like in my Interface Builder:

    Picker Goes at the top of the view, or "depeest"

    2)

    Set the "hidden" bit on the Picker object. This "dims" the Picker in IB, but at the same time don't forget to UN-HIDE it programatically when it's time for the object to appear.

    3)

    Or simply move the Picker out of the way of whatever you're doing and then move it into position (whether manually in IB before compiling or programmatically at run time).