问题描述
我的xib文件中有一个TextView.
I have a TextView in my xib file.
为它分配文本后,直到我双击它并真正更改文本的选择,它才会显示该文本:
After I assign text for it, it doesn't show the text till I double click it, and actually change the selection of the text:
双击之前:
双击后:
更改选择大小后:
您有什么想法,如何从一开始就显示文本?
Do you have any idea, how to show text from the beginning?
谢谢
推荐答案
我们找到了解决方案.当您尝试在视图不可见之前更新txt时,就会发生这种情况.
We found the solution. This situation happens, when you try to update the txt before the view is visible.
我们重写了函数viewDidAppear,并执行了以下代码:
We override the function viewDidAppear, and did this code:
// To fix the bug of not showing text in textView
self.txtViewShowDetails.text = nil;
self.txtViewShowDetails.text = self.mediaItem.mediaDescription;
[self.txtViewShowDetails setContentOffset:CGPointZero];
如果视图是动画的,或在动画的controlView中,则必须在动画完成后调用viewDidAppear.
If the view is animated, or inside animated controlView, we have to call the viewDidAppear after animation finished.
这篇关于UITextView不显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!