相关疑难解决方法(0)

如何在UITextField上模拟删除键?

我正在iPad上创建一个应用程序.我创建使用自定义键盘UITextFieldinputView财产.要在光标位置插入文本,我使用复制和粘贴方法(http://dev.ragfield.com/2009/09/insert-text-at-current-cursor-location.html),它可以正常工作.现在,我想创建删除键.我正在使用的代码是:

if (textField.text.length > 0) {
    textField.text = [textField.text substringToIndex:textField.text.length-1];
}
Run Code Online (Sandbox Code Playgroud)

但是,正如您所知,它只会删除最后一个字符,无论光标位于何处.有谁知道更好的解决方案?

非常感谢你!

iphone cocoa-touch uitextfield ipad

7
推荐指数
4
解决办法
9095
查看次数

标签 统计

cocoa-touch ×1

ipad ×1

iphone ×1

uitextfield ×1