菜鸟教程小白 发表于 2022-12-11 16:57:28

iOS 自定义键盘输入速度极慢


                                            <p><p>我使用 Swift 在 xcode 上创建了一个自定义键盘。它在模拟器上完美运行,但是当我在真实设备上测试它时,虽然键盘出现很快,但响应非常慢(最少 5 秒)。我不知道是什么问题。按下按钮时,键入文本需要花费太多时间,或者有时会崩溃。有什么想法吗?</p>

<pre><code>func handleTapOnButton(button: UIButton) {
    let buttonText = button.titleForState(.Normal)
    if let proxy = textDocumentaryProxy {
      if button.titleForState(.Normal) == &#34; &#34; {
            proxy.insertText(&#34; &#34;)
      } else {
            proxy.insertText(buttonText!)
      }
    }
    if globals.tapped != 3 &amp;&amp; (switchedToNumbers == false) {
      lowerCase()
      globals.tapped = 1
    }
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>如果您使用过 TouchUpInside,您可以进行 TouchDown Event。它可能会有所帮助。</p></p>
                                   
                                                <p style="font-size: 20px;">关于iOS 自定义键盘输入速度极慢,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/38306564/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/38306564/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS 自定义键盘输入速度极慢