iOS UITextField 響應鍵盤的return 事件


 

 

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 30)]
textField.returnKeyType = UIReturnKeySearch; //設置按鍵類型
textField.enablesReturnKeyAutomatically = YES; //這里設置為無文字就灰色不可點

 

在代理方法中響應

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self searchAction];
    [textField resignFirstResponder];
    return YES;
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM