UIAlertView not displaying complete message

ぃ、小莉子 提交于 2019-11-27 18:57:32

问题


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];
}

回答1:


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:

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.




回答2:


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:.



来源:https://stackoverflow.com/questions/4548387/uialertview-not-displaying-complete-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!