1

我有图像称为:

图片0001.png 图片0002.png ... 图片0234.png...

如何使 for 循环理解应该有多少个“0”?

 //this code crash
for (int i = 0; i < 234; i++)
{
    [myImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image000%i", i]]]; 
}

谢谢

4

1 回答 1

-2
for (int i = 0; i < 10; i++)
{

    [myImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image000%i", i]]]; 
}
for (int i = 10; i < 100; i++)
{

    [myImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image00%i", i]]]; 
}
for (int i = 100; i <= 234; i++)
{

    [myImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image0%i", i]]]; 
}
于 2013-02-12T17:30:05.970 回答