uisearchbar - searchBarSearchButtonClicked not firing -


i have researched question. looks common question nothing have tried has worked. new iphone app development , objective c. want @ point type in string in search bar field , return value in nslog() when search button on keypad tapped.

my header file looks this:

@interface listingmapviewcontroller : uiviewcontroller <uisearchbardelegate>   @property (weak, nonatomic) iboutlet uisearchbar *searchbar;  @end 

i have in class file:

#import "listingmapviewcontroller.h"  @interface listingmapviewcontroller ()   @end  @implementation listingmapviewcontroller   - (void)searchbarsearchbuttonclicked:(uisearchbar *)searchbar { searchbar.delegate =self;  [self handlesearch:searchbar]; nslog(@"user searched %@", searchbar.text);  }  @end 

when click search button nothing outputs. missing? thanks.

(answered in question edit. converted community wiki answer. see question no answers, issue solved in comments (or extended in chat) )

the op wrote:

solved setting searchbar delegate when view loads. guess setting in searchbarsearchbuttonclicked late.

- (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. [self.searchbar setdelegate:self];  //self.searchbar.delegate = self; <-- works } 

now when click search button on keypad text in search bar field outputs nslog(). hurray! on next challenge.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -