Reputation: 137
I was curious if I would be able to use a Uitextfield instead of a UiSearchBar because of the ease of resizing and the look. Are there any real drawbacks?
Upvotes: 4
Views: 734
Reputation: 2148
No there is no real drawback to use UITExtField
as an UISearchBar
. You just only need to add UITableView
,UISearchBar
datasource and Delegate methods.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if (textField == your textfield)
{
[textField resignFirstResponder];
yourtableview.hidden = NO;
return YES;
}
}
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
//....
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
//...
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
//...
}
Upvotes: 3
Reputation: 11770
Actually, no, no such reasons. Depends on what you are going to do. UISearchBar
is more optimized for searching, with its' look, functions, and callback methods. If you have to create custom interface element for searching, you would better start with UITextField
with a few UIButton
s, UISegmentedControl
s, whatever it takes.
Upvotes: 5