3
votes

I have the following function to display error messages to user. But it does not seem to show the complete message. It will display upto certain characters followed by ....

How can I make it show the entire message?

(void) showAlert:(NSString*)title forMessage:(NSString*) body
{
    UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:body delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
    [alertView release];
}
2
Approximately how long is the message you're trying to display? UIAlertView has a limit as to how long the message can be, after that it's clipped.sudo rm -rf
its close to 100 chars or so.. I think AlertView clips it around 60.. is there any way to show more characters?coder net

2 Answers

6
votes

There is a way.

When you present your alert, you can just implement this method:

- (void)willPresentAlertView:(UIAlertView *)alertView {
alertView.frame = CGRectMake(alertView.frame.origin.x, alertView.frame.origin.y -50
                             ,alertView.frame.size.width, 300);
}

Adjust the height to fit your need. It will look something like this:

alt text

If you need to move the button around, you can just add new lines (\n) to your message, and it will move the button down.

1
votes

As mentioned by sudo rm -rf, UIAlertView has a limit.

You can try creating your own "alert" that doesn't clip by creating a view controller and showing it using presentModalViewController:animated:.