1:添加代理 UITextFieldDelegate
2:return键的设置
self.mTFUserName.returnKeyType = UIReturnKeyNext;//Next按钮
self.mTFUserName.delegate = self;
self.mTFPassWord.returnKeyType = UIReturnKeyDone;//Done按钮
self.mTFPassWord.delegate = self;
3:响应事件函数
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == self.mTFUserName)
{
[self.mTFPassWord becomeFirstResponder];
}else if (textField == self.mTFPassWord){
[self mBTLogin:self.BTLogin];
}
return YES;
}
More:
typedef enum {
UIReturnKeyDefault, 默认 灰色按钮,标有Return
UIReturnKeyGo, 标有Go的蓝色按钮
UIReturnKeyGoogle,标有Google的蓝色按钮,用语搜索
UIReturnKeyJoin,标有Join的蓝色按钮
UIReturnKeyNext,标有Next的蓝色按钮
UIReturnKeyRoute,标有Route的蓝色按钮
UIReturnKeySearch,标有Search的蓝色按钮
UIReturnKeySend,标有Send的蓝色按钮
UIReturnKeyYahoo,标有Yahoo的蓝色按钮
UIReturnKeyYahoo,标有Yahoo的蓝色按钮
UIReturnKeyEmergencyCall, 紧急呼叫按钮
} UIReturnKeyType;
参考: