Return to Snippet

Revision: 51019
at September 12, 2011 23:39 by rabc


Initial Code
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
	
	// add toolbar above keyboard
	UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
	toolBar.barStyle = UIBarStyleBlackTranslucent;
	
	// done button
	UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithTitle:@"Fechar" 
															 style:UIBarButtonItemStyleBordered 
															target:self action:@selector(closeKeyboard)];
	
	UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
																		   target:nil 
																		   action:nil];
	
	toolBar.items = [NSArray arrayWithObjects:space, done, nil];
	[space release];
	[done release];
	
	textField.inputAccessoryView = toolBar;
	[toolBar release];

}

Initial URL


Initial Description


Initial Title
Add UIToolBar above keyboard

Initial Tags


Initial Language
Objective C