2012-10-19 41 views

回答

1

發送文本查看消息resignFirstResponder並且鍵盤將消失。如果您需要解除對返回鍵的響應,請考慮讓您的視圖控制器採用UITextViewDelegate協議。

[self.textViewInQuestion resignFirstResponder]; 

或者,你可以發送endEditing:消息給表視圖這樣的:

/* 
    Attempt to resign first responder status on any textfields within 
    the view's hierarchy. 
*/ 

[self.tableView endEditing:NO]; 


// OR we can.... 


/* 
    Force text fields within the view's hierarchy to resign first responder. 
    Textfield delegates cannot prevent this from happening so this is not 
    recommended if you need to perform field validation and prevent the user 
    from leaving the textfield. 

    However sometimes it is useful to be able to force the resignation of the 
    first responder status even with validation so it goes both ways really. 
*/ 

[self.tableView endEditing:YES];