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
Post a Comment