Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

johnellisdm

macrumors member
Original poster
i am trying to write a feature that will allow me to have a search text box that drops down from the navigation bar like the search bar does in safari for the iphone.

i'm very new to objective c and mac programming, but i'm able to get along great by looking at examples. unfortunately, there isn't an example for how to do this. any help or pointers would be appreciated.
 
nevermind, i went a different direction. i just put a text area in the custom right view of the nav bar like this:

Code:
UINavigationItem *navItem = self.navigationItem;
CGRect newFrame = CGRectMake(0, 0, 220, 25);
UITextField *textField = [[UITextField alloc] initWithFrame:newFrame];
   
textField.borderStyle = UITextFieldBorderStyleRounded;
textField.textColor = [UIColor blackColor];
textField.font = [UIFont systemFontOfSize:17.0];
textField.placeholder = [self searchPlaceholder];
textField.backgroundColor = [UIColor clearColor];
textField.delegate = self;
	
textField.keyboardType = UIKeyboardTypeDefault;	// use the default type input method (entire keyboard)
textField.returnKeyType = UIReturnKeyDone;
	
textField.clearButtonMode = UITextFieldViewModeWhileEditing;	// has a clear 'x' button to the right
	
UIImageView *searchIconView = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,25,25)];
searchIconView.image = [UIImage imageNamed:@"search.png"];
textField.leftView = searchIconView;
[searchIconView release];
textField.leftViewMode = UITextFieldViewModeAlways;
	
navItem.customRightView = textField;
[textField release];

this actually fits my situation better as i didn't really have an important title in the nav bar and i never have a "back" button where the search is taking place.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.