将UITextField的文本放入UIAlertView

时间:2013-08-07 05:45:51

标签: iphone ios xcode ipod

我试图将文本从文本字段放入UIAlertView,但它没有显示。它只是显示空白。

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Kik" message:self.kik.text delegate:self cancelButtonTitle:@"Got it!" otherButtonTitles: nil];

[alert show];

1 个答案:

答案 0 :(得分:0)

你应该试试,

if ( [self.kik.text length])
{
UIAlertView *alert = [UIAlertView alloc]initWithTitle:@"Kik" message:[NSString stringWithFormat:@"%@",self.kik.text] delegate:self cancelButtonTitle:@"Got it!" otherButtonTitles: nil];

[alert show];
}
else
{
UIAlertView *alert = [UIAlertView alloc]initWithTitle:@"Kik" message:@"Please enter a valid string" delegate:self cancelButtonTitle:@"Got it!" otherButtonTitles: nil];

[alert show];

}

检查..