Reputation: 441
I have an UIAlertView
with UITextView
.
on ViewDidAppear
I do [textView setText:]
with a large text, but the alert shows an empty textView, and only after I touch the textView to scroll, the text appears.
What should I do in order to make the text appear in the textView in the alert, without scrolling it to "refresh" it?
Thanks!
- (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];
}
Upvotes: 2
Views: 5626
Reputation: 1
Try with this:
UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Terms of Service"
message:[NSString stringWithFormat:@"%@ \n\n\n",myTextView.text]
delegate:self
cancelButtonTitle:@"Disagree"
otherButtonTitles:@"Agree",nil
];
Upvotes: 0
Reputation: 7803
Add \n characters in place of message in alert view . Then create a UILabel add add to alert view. Like this
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%@\n\n\n", @"Title"] message:@"\n" delegate:self cancelButtonTitle:NEVER_DISPLAY_BUTTON_TEXT otherButtonTitles:nil];
[alert addButtonWithTitle:@"Text"];
[alert addButtonWithTitle:@"Text"];
[alert addButtonWithTitle:@"Text"];
[alert addButtonWithTitle:@"Text"];
[alert show];
newTitle = [[UILabel alloc] initWithFrame:CGRectMake(10,-55,252,230)];
newTitle.numberOfLines = 0;
newTitle.font = [UIFont systemFontOfSize:15];
newTitle.textAlignment = UITextAlignmentCenter;
newTitle.backgroundColor = [UIColor clearColor];
newTitle.textColor = [UIColor whiteColor];
newTitle.text = [NSString stringWithFormat:@"%@",self.message];
[alert addSubview:newTitle];
You might need to adjust size of Uilable to match in your alert view.
Upvotes: 0
Reputation: 14113
This is because you have initially set message as @"\n\n\n\n\n\n\n" for UIAlertView
. Set your UITextView
first and then set UIAlertView
's message as textView's text.
Upvotes: 5