【问题标题】:Best practices for detecting when "user is typing" for chat functionalities?检测“用户正在输入”聊天功能的最佳实践?
【发布时间】:2014-07-25 05:01:21
【问题描述】:

我目前正在使用 PubNub 处理聊天的实时方面,并计划在用户输入或完成输入时更改 PNChannelstate

我的问题更多地与客户端有关,即如何测量 isTyping 状态之类的东西。由于屏幕键盘上的每次点击都必然有一些时间间隔,我想知道是否有一种“最佳实践”方法来测量屏幕点击之间的时间间隔以了解用户是否正在打字(例如,较慢的打字机与较快的打字机)与用户实际停止打字的时间?

谢谢!

【问题讨论】:

  • NSTimer 与检测击键结合使用。由您决定在最后一次检测到的击键之后可以经过多长时间并仍将其视为“打字”。

标签: ios uitextfield chat pubnub


【解决方案1】:

您可以在这些delegate methods of UITextField中查找

-(void)textFieldDidBeginEditing:(UITextField *)sender //method fires when u start begining typing anything in a textfield
-(BOOL) textFieldShouldReturn:(UITextField *) textField // method fires whenever u type anything in a textfield- returns character wise
-(void)textFieldDidEndEditing:(UITextField *)sender // fires when u finished typing stuffs in a textfield.

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2012-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-10
    • 2012-09-10
    • 2010-10-07
    • 1970-01-01
    相关资源
    最近更新 更多