Using a UISearchBar with showCancelButton=YES on iOS 5. Would like the cancel button to stay enabled when the keyboard drops down. Using the following code seems not to work:<
I had to solve the same problem in my application. Try doing your above code after a fractional delay, e.g.
[self performSelector:@selector(delayedEnable:) withObject:cancelButton afterDelay:0.001];
- (void)delayedEnable:(UIButton*)button {
button.enabled = YES;
}
It's ugly, but that's what it took to work for me. Alternatively, if you actually use a UISearchDisplayController to display the results, it should also fix the cancel button behavior for you (I think - I've delved into this issue less).