Steps in the UINavigationController subclass

I would like to subclass the UINavigationController to get extra freedom regarding the appearance of the controller.

I have graphics for different parts, bars, buttons, text, etc. Looking at the UINavigationController header file, it helps me a little, I don’t know where to start.

I have never subclassed / redefined the UIKit component before, it looks like it's like a Sherlock Holmes game.

What is the approach?

How to find out what needs to be redefined to get a certain part of the graphics "injected" the right place?

Do I need subclasses of UINavigationBar, UIBarButtonItem, etc. etc. to get a complete individual look?

How do I know if something doesn't meet Apple approval requirements?

Hope someone can point me in the right direction, I was able to find examples of changing small parts of the controller, rather than a complete setup by subclassing. Am I going about it wrong?

Thanks:)

+6
iphone customization uinavigationcontroller
source share
2 answers

You should not extend the UINavigationController.

Starting with iOS 6, this information is outdated. From Xcode 5 docs: Usually you use this class as is, but in iOS 6 and later, you can subclasses to customize the behavior of the class.

Initial obsolete information:

From the documentation:

The UINavigationController class implements a specialized view controller that controls the navigation of hierarchical content. This class is not intended to be a subclass. Instead, you use instances of this as it is in situations where the application user interface should reflect the hierarchical nature of your content.

You may want to create categories or subclass your UINavigationBar and potentially create custom UIButtons that you use to create UIBarButtonItems.

Whenever you work with a user interface component that extends from a UIView, what you should consider is a subclass and an override

- (void)drawRect:(CGRect)rect 

There are many examples here on stackoverflow or on the official Apple documentation site.

+8
source share

Now you can subclass the UINavigationController, see the updated documentation:

The UINavigationController class implements a specialized view controller that controls the navigation of hierarchical content. This navigation interface allows you to effectively present your data, and also makes it easier for the user to navigate this content. This class is usually used as is, but can be subclassed in iOS 6 and later.

UINavigationController class reference

+52
source share

All Articles