【发布时间】:2013-05-07 12:29:45
【问题描述】:
我有一个使用情节提要构建的 UITextField。我不想让用户更改光标的位置,并将其始终保持在文本末尾的文本字段中。
我试图在触摸阵列中更改光标的位置,但在选择文本字段时,然后再次通过触摸文本字段更改光标的位置时,位置会更改:
- (IBAction)amountBoxTouchDown:(id)sender {
UITextPosition *start = [amountBox positionFromPosition:[amountBox beginningOfDocument] offset:amountBox.text.length];
UITextPosition *end = [amountBox positionFromPosition:start
offset:0];
[amountBox setSelectedTextRange:[amountBox textRangeFromPosition:start toPosition:end]];
}
有人知道解决办法吗?谢谢
【问题讨论】:
-
请解释为什么要禁用光标位置。也许还有其他解决方案。
标签: iphone ios objective-c