本文只介绍在键盘上面增加一个按钮的方法:
UIToolbar *topView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 30)];
[topView setBarStyle:UIBarStyleDefault];
UIBarButtonItem *btnSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(dismissKeyBoard)];
NSArray *buttonArray = [NSArray arrayWithObjects:btnSpace,doneButton, nil];
[topView setItems:buttonArray];
[self.textViewDetails setInputAccessoryView:topView];
//关闭键盘 -(void) dismissKeyBoard{ [self.textViewDetails resignFirstResponder]; }