insertTextPlaceholder从ios 13开始可用
我正在尝试为textview创建一个占位符
if #available(iOS 13.0, *) {
msgBox.insertTextPlaceholder(with: CGSize(width: 210, height: 40))
}
我在此代码后看不到任何占位符
如何正确使用它?
首先,我认为您现在不应该使用它。因为the documentation非常差。并且UITextPlaceholder也没有有趣的信息。
我尚未发现有关此功能的任何有用信息。也许还没有准备好。
[我发现它在UITextView
的开头与传递给它的size
一起创建了一个空白区域。
1)UITextField
(白场),不使用insertTextPlaceholder
:
2)UITextField
使用insertTextPlaceholder
:
它会导致崩溃。例如,如果您添加以下内容:
let placeholder = textView.insertTextPlaceholder(with: CGSize(width: 100, height: 40))
textView.insertText("Test")
然后在UITextView
中输入内容,您会得到:
2020-04-29 14:20:10.264832 + 0300 StackOverflow [17081:284345] *由于未捕获的异常“ NSRangeException”而终止应用程序,原因:'*-[NSBigMutableString substringWithRange:]:范围{1,18446744073709551615};弦长5'***首先抛出调用堆栈:(...