【问题标题】:Trying to change image using int尝试使用 int 更改图像
【发布时间】:2011-03-23 20:34:45
【问题描述】:

我有这个代码:

  - (IBAction)next {
     static int index = 0;  // <-- here
    index++;
    // Set imageCount to as many images as are available
    int imageCount=16;
    if (index<=imageCount) {
        NSString* imageName=[NSString stringWithFormat:@"img%i", index];
        [picture setImage: [UIImage imageNamed: imageName]];
    }
}

它应该更改 imageview 图片上的图像,但它只是将 imageview 更改为白色背景,并且我的所有图像都命名为 img1 img2 img3 等我该如何进行这项工作?

请帮忙。

【问题讨论】:

    标签: iphone objective-c image sdk int


    【解决方案1】:

    我忘记的只是 stringWithFormat 末尾的 .jpg:@"img%i" ;) 哈哈

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多