i want simply to show a double va开发者_开发技巧lue on a uialert view it is possible?
Put the value into a formatted NSString
and send that to the alertView:
NSString *messageString = [NSString stringWithFormat:"@number = %.2f", 42.0];
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Title text" message:messageString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
How are you showing the UIAlertView
now? Something like the following should work:
double myDouble = 12.6;
NSString *alertString = [NSString stringWithFormat:@"%g", myDouble];
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:alertString
message:nil
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
[myAlert show];
精彩评论