ios - textDidChange method of UISearchBarDelegate has weird behavior with voice-to-text -


i have iphone app includes uitableview uisearchbar @ top of it. when user types uisearchbar uitableview's contents filtered appropriately. when user deletes text in uisearchbar search bar ceases first responder , tableview becomes unfiltered once again. here relevant delegate code:

- (void) searchbar:(uisearchbar *)searchbar textdidchange:(nsstring *)searchtext {     if(searchbar.text.length == 0)     {         [self.searchbar resignfirstresponder];         [self.mymodel stopfiltering];         [self.tableview reloaddata];     } } 

the problem is, when user speaks phone , attempts voice-to-text conversion (via siri) in search bar, textdidchange method returns empty string search text. have no way of knowing if user speaking phone or if deleted of text in field. behavior expected?

try , check if can step if statement :

 - (void) searchbar:(uisearchbar *)searchbar textdidchange:(nsstring *)searchtext     {         if([searchtext length]== 0)         {             [self.searchbar resignfirstresponder];             [self.mymodel stopfiltering];             [self.tableview reloaddata];         }     } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -