【发布时间】:2017-06-14 01:31:08
【问题描述】:
【问题讨论】:
标签: ios objective-c xcode keyboard
【问题讨论】:
标签: ios objective-c xcode keyboard
你可以试试这个代码:
注意:不要忘记让 textView 委托。
UIToolbar *keyboardDoneButtonView = [[UIToolbar alloc] init];
[keyboardDoneButtonView sizeToFit];
UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStylePlain target:self
action:@selector(doneClicked:)];
[keyboardDoneButtonView setItems:[NSArray arrayWithObjects:flexible, doneButton, nil]];
self.textView.inputAccessoryView = keyboardDoneButtonView;
IBAction函数:
- (IBAction)doneClicked:(id)sender
{
NSLog(@"Done Clicked.");
[self.view endEditing:YES];
}
【讨论】: