我有一个 UIAlertView
和 UITextView
。
在 ViewDidAppear
上,我使用大文本执行 [textView setText:]
,但警报显示一个空的 textView,只有在我触摸 textView 进行滚动后,文本才会出现。
我应该怎么做才能使文本出现在警报的 textView 中,而不需要滚动它来“刷新”它?
谢谢!
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
av = [[UIAlertView alloc]initWithTitle:@"Terms of Service" message:@"\n\n\n\n\n\n\n" delegate:self cancelButtonTitle:@"Disagree" otherButtonTitles:@"Agree",nil];
UITextView *myTextView = [[UITextView alloc] initWithFrame:CGRectMake(12, 50, 260, 142)];
[myTextView setTextAlignment:UITextAlignmentCenter];
[myTextView setEditable:NO];
myTextView.layer.borderWidth = 2.0f;
myTextView.layer.borderColor = [[UIColor darkGrayColor] CGColor];
myTextView.layer.cornerRadius = 13;
myTextView.clipsToBounds = YES ;
[myTextView setText:@"LONG LONG TEXT"];
[av addSubview:myTextView];
[myTextView release];
[av setTag:1];
[av show];
}
最佳答案
这是因为您最初将 UIAlertView
的消息设置为 @"\n\n\n\n\n\n\n"。首先设置 UITextView
,然后将 UIAlertView
的消息设置为 textView 的文本。
关于iphone - UIAlertView 中的 UITextView 大文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11467244/