Ahmed
Ahmed

Reputation: 945

Best practice to add an Application wide Header View in iOS

Let's say my main view controller will be a tab bar with misc sub view controllers (i.e the first will be navigation controller, the second will a subclass of uiviewcontroller, etc)

Now I want to add a static header view (will contain at least a logo uiimageview like websites)

so what is the best practice to achieve this?

Upvotes: 0

Views: 131

Answers (2)

ravron
ravron

Reputation: 11221

EDIT: As Mark Adams explains in the comments, below, this is not a good strategy. I'll leave it as an note on what not to do.


"Best practice" is a dicey term, but what immediately comes to mind for me is to make your UITabBarController the root and only view controller of a parent UINavigationController. Then you can put whatever logo UIImageView you like in the navigation bar.

Upvotes: 1

RileyE
RileyE

Reputation: 11084

If you're not going for a UINavigationBar style, then I would recommend subclassing UIView and creating your custom view and using a simple implementation and offset value to add it to each of your UIViewControllers. Its a hassle, but it avoids having to throw on unnecessary UINavigationControllers to your project.

As for best practice, you should alway keep the UITabBarController as the root of your window, rather than having a UINavigationController with a UITabBarController as a root.

Also, I do appreciate the other poster's name.

Upvotes: 0

Related Questions