target-c: программирование iphone: отображение переменных в представлении UIAlert - PullRequest
0 голосов
/ 14 июля 2010

я хочу просто показать двойное значение в представлении uialert, это возможно?

Ответы [ 2 ]

3 голосов
/ 14 июля 2010

Поместите значение в отформатированный NSString и отправьте его в 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];
0 голосов
/ 14 июля 2010

Как вы показываете UIAlertView сейчас? Должно работать что-то вроде следующего:

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