(Xcode6, iOS8, iPhone, Swift)
I would like to add a Continue button to the right of the navigation bar.
How can I do that? I tried to use some of the methods available in the UIBarButtonItem, but I can't get it to work.
My best so far:
var b = UIBarButtonItem(title: "Continue", style: UIBarButtonItemStyle, target: self, action: nil) self.navigationItem.rightBarButtonItem = b
But I get an error on the first line. He doesn't like the "style" parameter. I also tried
var b = UIBarButtonItem(title: "Continue", style: UIBarButtonItemStylePlain, target: self, action: nil)
But no luck. Still stuck in the style parameter. Any ideas? tyvm Keith: D
EDIT: for posterity, the following line also includes the action parameter:
var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:"sayHello")
Link: How to set an action for a UIBarButtonItem in Swift
swift uibarbuttonitem
kmiklas
source share