开发者

Trying to change image using int

开发者 https://www.devze.com 2023-01-09 23:23 出处:网络
I have this code: - (IBAction)next { static int index = 0;// <-- here index++; // Set imageCount to as many images as are available

I have this code:

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

and it is supposed to change the i开发者_JS百科mage on the imageview picture but it just changes the imageview to a white background and all my images are named img1 img2 img3 etc how do I make this work?

Please help.

Will


All I forget was the .jpg on the end of stringWithFormat:@"img%i" ;) Haha

0

精彩评论

暂无评论...
验证码 换一张
取 消