Search code examples
iosuiviewcontrolleruipickerview

Create a picker view to use on multiple ViewControllers


My app has multiple screens all of which are different and not related however i must have a burger button which opens the same drop down menu on each screen.

Is it possible in iOS to create the menu once as a view and reuse it on each screen or do I have to create it on each ViewController and implement it.

Any explanation as to how to achieve this would be great.


Solution

  • The best thing would be to implement a custom view or custom control which you reuse in every Controller you want. The good thing is with the new storyboard and a xib file you can even see it in realtime in the storyboard (#ibdesignable).

    Check out this: Creating a Custom View That Renders in Interface Builder (Apple Documentation)

    Or a great tutorial: Custom UI components