【问题标题】:iPhone SDK simple alert message questioniPhone SDK 简单提示信息问题
【发布时间】:2010-04-13 13:13:26
【问题描述】:
char asd='a';
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:asd
               delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alert show];
[alert release];

以上代码未在 iPhone 模拟器中编译。 这是为什么? :)

【问题讨论】:

  • 你得到什么错误信息?

标签: iphone sdk simulator


【解决方案1】:

您正在尝试传递 char ,其中应该是 NSString 。阅读 Objective-C 和 Cocoa/Cocoa Touch 文档。

要解决您的问题,请尝试以下操作:

NSString *asd = @"a";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:asd
               delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alert show];
[alert release];

【讨论】:

    【解决方案2】:
    1. 你没有在 iPhone 中编译 模拟器,你在你的 Mac 上编译。
    2. 您是否收到错误消息?
    3. 消息参数应该是NSString,而不是char

    【讨论】:

      【解决方案3】:

      替换

      char asd='a';
      

      NSString *asd=@"a";
      

      它应该在它之后编译...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-05-06
        • 2010-09-26
        • 1970-01-01
        • 1970-01-01
        • 2011-04-06
        • 1970-01-01
        • 2010-12-25
        • 2012-02-09
        相关资源
        最近更新 更多