I am working on a project where there is a requirement for a custom uinavigationbar. The desired effect is a visualisation on the stack of views contained within the navigationcontroller.

Imagine that for each view you move forwards a new button appears in the navigationbar for the view you have just left e.g.

View 1 >> View 2 >> View 3

I am quite comfortable in creating custom resuable iOS components but I am very interested to hear how other people would approach this task.

The instance I have running at the moment is a subview of UIView and on init I create the navigationbar by adding UIButtons for entries detailed in an array of dictionaries provided by the delegate class.

In psudeo code:

@protocol NavDelegate

- (void)UIButtonClicked;

@end

@protocol NavDataSource

 - (NSMutableArray *)arrayOfDictionaries;

@end

@interface Navbar : UIView
<NavDelegate,NavDataSource>
{
    //create and synthesize delegate and datasource objects
}
@end

@implementation NavBar

- (id)init
{
//override and instantiate necessary objects
}

- (void)layoutSubviews
{
//here I use the number of dictionaries in the delegate returned array to add UIButtons to
//a UIView adding control events for when the button is clicked
}

@end

It works, but I cant help feeling that there is a more elegant solution out there.

I would also be interested to hear if people think that this is a practice that should be avoided. I am reluctant at all times to 'reinvent the wheel' but the project stakeholders think this is a good UI element. If the tide of opinion is 'avoid at all costs' then I will certainly put the argument back to them.

Thanks in advance guys

有帮助吗?

解决方案

Apple, I believe, in their own docs about navigation controllers, frown on this sort of UI.

Sounds like your stakeholders have a website breadcrumb mindset... which is the wrong mindset to have, at least in my opinion, for mobile app design. Are they UI or UX people? If not, well... perhaps they need one.

That being said, they are the customer. :-)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top