If timelineSearchBar
is indeed a property of type UISearchBar
then these calls should actually fail on both devices. UISearchBar
does not inherit from UITextField
, and so does not implement the two methods you are trying to call. Your cast to UITextField
is unsafe and is probably the source of your errors.
If you really want to change these properties of your search bar, you can look through the subviews until your find the actual UITextField
, and set your properties on that. The following method will find the text field from the subviews:
-(UITextField*)findTextFieldInSubviewsRecursively:(UIView*)view
{
if([view isKindOfClass:[UITextField class]]){
return (UITextField*)view;
}
for (UIView *subView in view.subviews){
UITextField* field = [self findTextFieldInSubviewsRecursively:subView];
if(field != nil){
return field;
}
}
return nil;
}
Then you just need to set your values:
UITextField* searchBarTextField = [self findTextFieldInSubviewsRecursively:self.timelineSearchBar];
// Set your stuff on the text field
But this approach is probably not recommended and may not even work