Bất cứ khi nào tôi mở rộng một UITextView đến một kích thước lớn hơn 512, với mã như:UITextView chiều rộng lớn hơn 512 không hiển thị văn bản
textView = [[UITextView alloc] initWithFrame: CGRectMake(0, 0, 513, 1024)];
Nó không hiển thị bất kỳ văn bản nữa ... 512 công trình , bất kỳ kích thước nào dưới đây cũng vậy, nhưng bất kỳ thứ gì lớn hơn 512 và nó dừng hiển thị bất kỳ văn bản nào. Toàn bộ mã:
- (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];
}
Tôi đang gặp sự cố tương tự chính xác này (bao gồm giải pháp <512px ") trong một lần xem văn bản được khởi tạo từ NIB. Điều kỳ lạ là văn bản ở đó (có thể chỉnh sửa, có thể chọn) nhưng không hiển thị. Sau khi nhấn enter trong textview, văn bản sẽ xuất hiện. Thật kỳ quặc. – mvds
Nếu nó hữu ích cho bất cứ ai, tôi đã có một vấn đề tương tự tại http://stackoverflow.com/questions/10211133/ios-uitextview-not-displaying-correctly-bug – Jacksonkr