lea*_*ner 6 keyboard uitextview ios xcode5
需要向用户显示用于评论输入的多行文本字段,我使用的是 UITextView 而不是 UITextField。我想textFieldShouldReturn在我的 UITextView 上使用将数据发送到服务器。我该怎么做?根据我目前的阅读,该方法仅适用于 UITextField。那么 UITextView 的等价物是什么?
通过将 UITextViewDelegate 添加到 viewControllerHeader
@interface ViewController : UIViewController<UITextViewDelegate>
Run Code Online (Sandbox Code Playgroud)
这将允许您访问 UITextViewDelegate 方法,其中有几个方法可以让您知道用户何时按下返回键或让您知道他们何时完成编辑,例如
- (void)textViewDidEndEditing:(UITextView *)textView{
//From here you can action your methods to send the data to your server as required etc.
}
Run Code Online (Sandbox Code Playgroud)
还有这个方法
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
//Which you can use to listen for the @"\" return action if you prefer.
}
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助
| 归档时间: |
|
| 查看次数: |
2656 次 |
| 最近记录: |