Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple UIBarButtonItem on LEFT side of UINavigationBar with a BACK button

I'm able to follow http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/ to add multiple buttons on the RIGHT side of the UINavigationBar. However, I cannot find any solution to add multiple buttons on the LEFT side. I want to add an "Edit" button next to the Back button in the UINavigation Bar for my iPad app. It's kinda like the "Sign Out" and "Edit" buttons in the iPad YouTube app.

Anyone has any idea on how to implement it?

Thanks

like image 973
Kelvin Avatar asked Nov 04 '22 23:11

Kelvin


1 Answers

 let editImage   = UIImage(named: "YourImageName1")!

 let searchImage = UIImage(named: "YourImageName2")!

let editButton   = UIBarButtonItem(image: editImage,  style: 
.Plain, target: self, action: "didTapEditButton:")

let searchButton = UIBarButtonItem(image: searchImage,  style: 
 .Plain, target: self, action: "didTapSearchButton:")

navigationItem.leftBarButtonItems = [editButton, searchButton]

And In the End Make Functions For Tapping Buttons

func didTapEditButton(sender: AnyObject)

{

 ...
}

func didTapSearchButton(sender: AnyObject)

{

...
}
like image 171
Asad Khatri Avatar answered Nov 11 '22 03:11

Asad Khatri