• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

UINavigationController's UIToolBar and global actions

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic