iphone - How to access searchBar's clear text button? -


when hit "clear" button (the 1 appears when editing) on tableview search, trying keyboard disappear. how can detect when "clear" button clicked, can resign firstresponder? tried in textdidchange method:

if (searchbar.text == @"") {     [searchbar resignfirstresponder];     nslog(@"clear called"); } 

which did not work...and tried:

 if (searchbar.text == nil) {     [searchbar resignfirstresponder];     nslog(@"clear called"); } 

neither methods show called. ideas?

edit: resignfirstresponder not seem working. keyboard stays on screen. what's doing wrong?

for string comparision u should use

if([searchbar.text isequaltostring: @""]) 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -