jamonholmgren / ProMotion

ProMotion is a RubyMotion gem that makes iPhone development less like Objective-C and more like Ruby.
MIT License
1.26k stars 147 forks source link

Allow for multiple navigation bar items #441

Open forrestgrant opened 10 years ago

forrestgrant commented 10 years ago

To accomplish this, I've done the following:

first_button = UIBarButtonItem.alloc.initWithImage(first_image,
  style: UIBarButtonItemStylePlain,
  target: self,
  action: :first_action
)
second_button = UIBarButtonItem.alloc.initWithImage(second_image,
  style: UIBarButtonItemStylePlain,
  target: self,
  action: :second_action
)

self.navigationItem.rightBarButtonItems = [first_button, second_button]

It would be nice to implement something in PM such as:

set_nav_bar_buttons {
  right: [
    { image: first_image, action: :first_action },
    { image: second_image, action: :second_action }
  ],
  left: [
    { image: left_image, action: :left_action }
  ]
}
jamonholmgren commented 10 years ago

@markrickert, @silasjmatson, @ryanlntn, thoughts on the above API? Any alternatives?

PM 2.1+.

markrickert commented 10 years ago

What if we made nav_bar_buttons an accessable array? We could do something like:

set_left_nav_bar_button whatever
left_nav_bar_buttons << some_other button

Just an idea, but may be half-baked.

jamonholmgren commented 10 years ago

I was tossing around that idea myself. Wouldn't be as consistent with our previous API, though.