Ryan
Ryan

Reputation: 1141

One Common View In Every ViewController

I am having a hard time wording this when searching the internet so I am just going to ask the question.

I have an options view in my app that slides into view when the user clicks a button. This options view will display app information like settings. I want this options view to be displayed on every view controller in my app. I do not want to copy and paste the code for the options view into every viewcontroller file. The options view has quite a few outlets and actions and also calls many delegates.

How can I reuse this options view in all my view controllers without adding all the outlets, actions, and delegate methods each time?

I was going to make a new file with public methods, but I would still have to copy the outlets. Would this public methods file have to include delegate methods as well then?

Let me know if my question does not make sense. I am hoping there is a standard way of implementing something like this.

Upvotes: 1

Views: 430

Answers (2)

rdelmar
rdelmar

Reputation: 104082

You can just have the options view be the view of an options view controller, and show it modally from any view controller you want. Is there some reason you're not doing it this way? This is the usual way to do this, not by having a view that you reuse in different controllers.

Upvotes: 4

Dan F
Dan F

Reputation: 17732

Add the options as a subview of the window, then make your App Delegate handle all of the options view's outlets

Upvotes: 2

Related Questions