开发者

objective-c : iphone programming : Showing variables on UIAlert view

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜