【发布时间】:2011-03-13 21:02:47
【问题描述】:
每当我将 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 中遇到了同样的问题(包括
-
如果对任何人有帮助,我在stackoverflow.com/questions/10211133/…也遇到了类似的问题
标签: ipad uitextview