1.创建对像文本输入框
UITextField *textField = [[UITextField alloc]initWithFrame:CGRextMake];
2.设置键盘按钮类型
[textField setReturnKeyType:UIReturnKeyDone];
3.设置输入框的Delegeate
textfield.delegate = self;
4.实现Delegate方法
- (void)textFieldDidEndEditing:(UITextField *)textField { [textField resignFirstResponder]; } - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; }
Swift 在编译app时检查xcode/ios sdk版本号