ios - UISearchBar Cancel Button Not Working -
i have uisearchbar on mkmapview i'm going use search annotations. i'm having trouble getting cancel button work. create search bar in viewdidload method this:
uisearchbar *searchbar = [[uisearchbar alloc] init]; searchbar.frame = cgrectmake(0, 0, 320,44); searchbar.showsbookmarkbutton = no; searchbar.showscancelbutton = yes; [self.view addsubview:searchbar];
and i've implemented method cancel button:
- (void)searchbarcancelbuttonclicked:(uisearchbar *)searchbar { [searchbar resignfirstresponder]; }
what doing wrong?
you haven't assigned search bar delegate.
searchbar.delegate = self
Comments
Post a Comment