aspose file tools*
The moose likes iOS and the fly likes UINavigationController's UIToolBar and global actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » iOS
Bookmark "UINavigationController Watch "UINavigationController New topic
Author

UINavigationController's UIToolBar and global actions

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

I've asked this question here as well.

In my application I am using UINavigationController to nav around to different views. I turned on the Shows Toolbar option in the interface builder for my UINavigationController. I understand how to add items to this toolbar. However, I have a couple of items that will be the same throughout the entire application, they show up on every view; Logout & Menu.

I'm looking for a way to attach events to these buttons on each controller so that the same method is called. What I mean is, I don't want to have to write the IBAction methods in every controller. This would duplicate the same logic 10+ times.

Thanks for any advice.


GenRocket - Experts at Building Test Data
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Objective-C does have inheritence. ;)

Maybe create a base interface/class that all your controller's extend, then they all will have the same IBAction. You can even not implement the action in the controllers, but delegate it even more. Maybe the delegation is overkill.

It is really easy for me to lose all the great OO stuff that I usually do in Java, when I am coding Objective-c. But I think in the long run, all of us would be better to get into the habit of doing good OO in iPhone development.

And Gregg, you can be the Guinea Pig. Let me know how it goes. ;)

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Mark, that's all I needed; a nudge in the right direction. Here's how I accomplished this...





Some boilderplate left out for brevity. Works like a champ. Thanks, Mark.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UINavigationController's UIToolBar and global actions