I have a class and use UICollectionViewController, UICollectionViewDelegateFlowLayout , UISearchBarDelegate
I want use searchbar in Navigation View , but when I clicked on Cancel Button or SearchButton , searchBarSearchButtonClicked and searchBarCancelButtonClicked , non of them was called.
but I use this function and this func was called :
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
println("search is working ")
}
this is my viewDidload func:
override func viewDidLoad() {
super.viewDidLoad()
let searchBar = UISearchBar()
searchBar.delegate = self
searchBar.sizeToFit()
navigationItem.titleView = searchBar
}
and this is search and cancel func:
func searchBarCancelButtonClicked(searchBar: UISearchBar) {
println("cancel button called")
}
func searchBarSearchButtonClicked(searchBar: UISearchBar) {
println("search button called")
}
So , what is wrong? searchBar func is called when I write something in searchbar but when click on searchButton and cancel button nothing happen!?
I use simulator iphone ,So search button is enter button of keyboard but I used another button , then nothing happen. now I use enter , and every thing is ok. this is very funny!:D