UISearch panel does not call searchBarTextDidBeginEditing

I have a simple view controller with uisearchbar and uitable . My problem is that when the search bar is displayed, I see the delegate function searchBarShouldBeginEditing , but not searchBarTextDidBeginEditing (and because the keyboard is not open and the search is not editable)

I tried to implement the searchBarShouldBeginEditing delegation function , returning YES, set the search bar as the first responder, but we won’t get searchBarTextDidBeginEditing ...

Any idea what could happen?

Some codes:

controller.h

@interface ViewController : UIViewController <UISearchBarDelegate> { UISearchBar * searchbar; } @property (nonatomic, retain) IBOutlet UISearchBar* searchbar; @end 

controller.m

 @synthesize searchbar; - (BOOL)respondsToSelector:(SEL)sel { NSLog(@"Queried about %@", NSStringFromSelector(sel)); return [super respondsToSelector:sel]; } - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar { NSLog(@"searchBarShouldBeginEditing -Are we getting here??"); return YES; } -(void) searchBarTextDidBeginEditing:(UISearchBar *)searchBar { NSLog(@"searchBarTextDidBeginEditing -Are we getting here??"); } 

From cousrse, my class has a lot of code (which, of course, influences the search bar somehow), but if someone had similar problems with the search bar, he would be very appreciated by his answer;)

I tried to make a simple application with only a search bar and obviously it works ...

EDITING:

Testing a bit I found that this is not something related to uisearchbar, as I added TextField, getting the same result (only the calling function textFieldShouldStartEditing)

The application has all the view controllers inside the cotroller UITabBar, but I don’t think that this can cause all this mess ...

EDITING2:

Really strange behavior: setting the IBAction function to the TouchDown event in UITextfield works fine, but setting the IBAction function for EditingDidBegin never works ...

Why this event can not be called?

+6
source share
2 answers

Have you set the delegate property?

 searchbar.delegate = self; 
+13
source

Maybe you call [searchbar resignFirstResponder] . That was in my similar problem.

0
source

Source: https://habr.com/ru/post/900767/


All Articles