隱藏鍵盤方法

指定文本框代理

- (void)viewDidLoad {

[ super viewDidLoad];

txt.delegate = self;

}


按回車隱藏鍵盤

- (BOOL)textFieldShouldReturn:(UITextField *)textField

{

[textField resignFirstResponder];

return YES;

}

點擊view其它地方隱藏鍵盤

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

[txt resignFirstResponder];

}


//觸摸事件

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

發佈了18 篇原創文章 · 獲贊 22 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章