【问题标题】:Putting the text of a UITextField into a UIAlertView将 UITextField 的文本放入 UIAlertView
【发布时间】:2013-08-07 05:45:50
【问题描述】:

我试图将文本字段中的文本放入 UIAlertView,但未显示。它只是显示空白。

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

[alert show];

【问题讨论】:

  • 你有没有试过NSLog(@"%@",self.kik.text);看看你得到了什么?如果它是 nil 或空白,那么这就是你的问题。
  • 感谢您解决了所有问题!原来我是在拍空白。 @Jsdodgers

标签: iphone ios xcode ipod


【解决方案1】:

你应该试试,

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

}

检查..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-11
    • 1970-01-01
    相关资源
    最近更新 更多