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:
for (id subView in self.searchControl.subviews)
{
if ([subView isKindOfClass:[UIButton class]])
{
UIButton *cancelButton = (UIButton *)subView;
[cancelButton setEnabled:YES];
break;
}
}
The subView is actually a UINavigationButton which appears not to be subclassed off of UIButton. What am I missing here??????? Also cannot find any info on the UINavigationButton class in the Apple docs.
Best Answer
Set your searchbar delegate and than put this code.
Swift 3.0