How to disable search button in uisearchbar

Hi i want to disable search button in keyboard for uisearchbar. i have customized the search button.

iPhone 4S, iOS 5

Posted on Jun 13, 2012 3:50 AM

Reply
1 reply

Jun 16, 2012 7:27 PM in response to PMahesh

When you say "customized the search button" have you customized the appearance of the search button on the search bar using something like setImage:forSearchBarIcon:state:? How does that necessitate disabling the keyboard button?


You can enumerate the UISearchBar subviews to get the UITextField. That allows some control over the keyboard. But not enabling/disabling a key button. This example shows the Done button instead of the Search button when entering text in the search bar.


// searchBar is an IBOutlet for the UISearchBar on the view

for (UIView *subview in searchBar.subviews) {

if ([subview conformsToProtocol:@protocol(UITextInputTraits)])

[(UITextField *)subview setReturnKeyType:UIReturnKeyDone];

Read this question that might be similar to yours. One solution appears to use a private API so is probably not useful.

http://stackoverflow.com/questions/9721668/how-can-i-disable-enable-uisearchbar- keyboards-search-button

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to disable search button in uisearchbar

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.