使用Swift选择UITextView的全文

时间:2018-02-05 14:53:41

标签: swift uitextview uitextrange

我试着这样做,就像我用UITextField做的那样:

textView.selectedTextRange = textView.textRange(from: textView.beginningOfDocument, to: textView.endOfDocument)

我做错了什么?

1 个答案:

答案 0 :(得分:4)

在选择文本字段第一响应者之前,您应该这样做:

awk -F, '
BEGIN {
    split("site,fdate,prcp,snow,tmp2m,dpt2m,wchill,wind10m",tags)
    print "<table id=\"alert\">"
}
{
    printf "<tr>"
    for (i=1; i in tags; i++) {
        printf "<td class=\"%s\">%s</td>", tags[i], $i
    }
    print "</tr>"
}
END { print "</table>"}
' /home/weather/csv

...或者,更好的是,只需致电textView.becomeFirstResponder() textView.selectedTextRange = textView.textRange(from: textView.beginningOfDocument, to: textView.endOfDocument)

selectAll