我創建了一個UITextView
編程與後續:iOS UITextView - setText方法不顯示我的文本?
messageBodyTxt = [[UITextView alloc] initWithFrame:CGRectMake(36, 204, 763, 251)];
[messageBodyTxt setTextColor:[UIColor colorWithRed:0.627 green:0.627 blue:0.627 alpha:1]];
[messageBodyTxt setBackgroundColor:[UIColor clearColor]];
[messageBodyTxt setText:@"some random text"];
然而,的setText屬性不顯示我的文字。我的頭文件是這樣的:
#import <UIKit/UIKit.h>
@interface MessageView : UIView {
UITextView *messageBodyTxt;
}
@end
,我已經把它添加到我的觀點,像這樣:
[self addSubview:messageBodyTxt];
我所有的其他UILabel
的功能正常時,我使用的setText方法,但我似乎無法得到UITextView
顯示任何東西。
任何想法?
嘗試'messageBodyTxt.text = @「一些隨機文本」;'代替 – 2012-01-26 20:52:05
將textview添加到屏幕的位置。如果將背景顏色更改爲明顯的東西,你還能看到它嗎?不知道爲什麼你的代碼無法工作,除非它沒有在屏幕上使用。 –
@AmitShah同意。另外,在你的視圖層次結構中它是什麼?它會被另一個不透明的UIView遮擋嗎? – ddodev