7
每当我拉开一个UITextView的大小大于512,用这样的代码:UITextView的宽度大于512不显示文本
textView = [[UITextView alloc] initWithFrame: CGRectMake(0, 0, 513, 1024)];
它已经不显示任何文本... 512个工程,也低于此值,但大于512的任何值都会停止显示任何文本。完整的代码:
- (void)loadView {
self.navigationItem.hidesBackButton = YES;
self.view = [[UIView alloc] init];
self.view.backgroundColor = [UIColor blackColor];
RDLocalizedStrings * strings = [RDLocalizedStrings defaultLocalizedStrings];
NSString* message = [strings getStringWithKey: @"noUpdatesAvailableText"];
CGFloat messageFontSize;
RDRectCreate(message);
BOOL iPad = NO;
#ifdef UI_USER_INTERFACE_IDIOM
iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#endif
if (iPad) {
RDRectWrite(message, 0, 100, 513, 200);
messageFontSize = 20.0;
} else {
RDRectWrite(message, 0, 0, 320, 480);
messageFontSize = 20.0;
}
textView = [[UITextView alloc] initWithFrame: messageRect];
textView.text = message;
textView.backgroundColor = [UIColor redColor];
textView.textAlignment = UITextAlignmentCenter;
textView.textColor = [UIColor whiteColor];
textView.font = [UIFont systemFontOfSize: messageFontSize];
textView.editable = NO;
[self.view addSubview: textView];
}
我在从NIB实例化的textview中遇到了完全相同的问题(包括<512px“解决方案”)。奇怪的是,文本在那里(可编辑,可选),但只是不可见。在文本视图中输入后,出现文本。真奇怪。 – mvds 2011-02-03 01:07:55
如果它对任何人都有帮助,那么我在http://stackoverflow.com/questions/10211133/ios-uitextview-not-displaying-correctly-bug上遇到类似的问题 – Jacksonkr 2012-04-18 22:17:16