Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable UISearchBar

I have a -as I hope- very simple question: how to disable an UISearchBar in IOS5 to avoid user interaction? I can't find setEnabled or something like this...

Thanks!

like image 363
Tom Avatar asked Feb 06 '12 23:02

Tom


3 Answers

Have you tried:

[searchBar setUserInteractionEnabled:NO];

?

like image 142
Conrad Shultz Avatar answered Nov 07 '22 08:11

Conrad Shultz


In addition to setting user interaction, I also adjusted the alpha value as well, to make the appearance unique.

searchbar.alpha = .75;
like image 14
flizit Avatar answered Nov 07 '22 06:11

flizit


Try this

// Normal 
self.searchDisplayController.searchBar.userInteractionEnabled = YES;
self.searchDisplayController.searchBar.translucent = YES;
self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleDefault;
self.searchDisplayController.searchBar.backgroundColor = [UIColor clearColor];

// Faded out
self.searchDisplayController.searchBar.userInteractionEnabled = NO;
self.searchDisplayController.searchBar.translucent = NO;
self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
self.searchDisplayController.searchBar.backgroundColor = [UIColor lightGrayColor];
like image 6
Mazen Kasser Avatar answered Nov 07 '22 06:11

Mazen Kasser