我正在使用 swift 语言开发一个 IOS 应用程序,我想从 uitableview 的行转到 uitextview 以显示一些文本,并且我想使用 uitextview 的属性文本属性,但它不起作用。如何做到这一点?
最佳答案
首先,你不能继续使用 UITextView
;您只能连接到另一个 View Controller 。但也许您的意思是说您的 Segue 转到其中包含 UITextView
的 View Controller 。如果是这样,则按住 Control 键并将 Segue 从 TableView 单元格拖动到另一个 View Controller ,并为 Segue 提供标识符。然后,在您的 TableView Controller 中,实现:
func prepareForSegue(_ segue: UIStoryboardSegue, sender sender: AnyObject?) {
if segue.identifier == "the-segue-id-that-you-put-in-your-storyboard" {
// Cast your destination view controller to the specific type
if let destinationVC = segue.destination as? <your-view-controller-type> {
destinationVC.textView.attributedText = <your-string>
}
}
}
关于ios - 如何在 swift 中从 uitableview 转至 uitextview 并使用 nsattributedtext 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36483952/