Problem: I want my textFieldSearchAddress to display a seperate viewcontroller.

textfield.png

Short Answer: Hide the keyboard by using

[textField resignFirstResponder]

then show the view controller.

  1. Implement a UITextFieldDelegate.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
	[textField resignFirstResponder];
	[self show];
	return NO;
}

Be careful with the BOOL return of textFieldShouldBeginEditing. From the docs: “YES if an editing session should be initiated; otherwise, NO to disallow editing.”

  1. Show the view controller.
- (IBAction)show{
	NSLog(@"show");
 
	AddressViewController *addressViewController = [[AddressViewController alloc] initWithNibName:@"AddressViewController" bundle:nil];
	UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:addressViewController];
	[self presentModalViewController:nav animated:YES];
 
	[addressViewController release];
	[nav release];
 
}

Download SimpleIB-textfield_custom_view_controller.zip