ios UITextView 显示不正确(错误?) [英] ios UITextView not displaying correctly (bug?)
问题描述
我在启用分页的 UIScrollView
中水平布置了 10 个 UITextView
.
I have 10 UITextView
s laid out horizontally in a UIScrollView
that has paging enabled.
当我的视图被初始化并进入视图时,初始页面的 UITextView
的文本不会出现.背景颜色显示正常,但文本在屏幕上不可见.
when my view is initd and brought to view, the initial page's UITextView
's text does not appear. The background color shows up fine, but the text is not visible on screen.
现象如下:
只要您拖动 UIScrollView
甚至 1px,文本神奇地就会显示它自己.这是怎么回事?我该如何解决这个问题?
As soon as you drag the UIScrollView
even 1px the text magically displays it's self. What's the deal? How can I fix this?
** 编辑 - kai 的代码 **
** edit - code for kai **
[self.messageBodyTxt setFont:[UIFont fontWithName:@"MuseoSlab-300" size:16.67]];
[self.messageBodyTxt setText:[[data objectForKey:@"Description"] valueForKey:@"text"];
注意 - 我已经尝试过使用系统字体.此外,此代码适用于不同的视图,所以我不确定是什么.
Note - I've already tried using a system font. Also, this code works on a different view so I'm not sure what'sup.
推荐答案
CGRect f = self.myTextView.frame;
f.size.height += 1;
[self.myTextView setFrame:f];
因为我的 UITextView
已经在 XIB
文件中,所以我只是将现有高度修改了 1px 和 viola.正如@larsacus 指出的那样,只有当模块的宽度超过 512px 时才需要这样做.
Because my UITextView
is already in a XIB
file I just modify the existing height by 1px and viola. As @larsacus pointed out, this is only necessary when the module's width is over 512px.
这篇关于ios UITextView 显示不正确(错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!