我將如何創建一個隨機圖像發生器,不重複的圖像,直到它已經通過他們所有的一次?隨機圖像發生器,不重複xcode
例如:
- (IBAction爲)randomimagebutton {
int randomimages = rand() % 5;
switch (randomimages) {
case 0:
imageview.image = [UIImage imageNamed:@"IMAGE_001.png"];
break;
case 1:
imageview.image = [UIImage imageNamed:@"IMAGE_002.png"];
break;
case 2:
imageview.image = [UIImage imageNamed:@"IMAGE_003.png"];
break;
case 3:
imageview.image = [UIImage imageNamed:@"IMAGE_004.png"];
break;
case 4:
imageview.image = [UIImage imageNamed:@"IMAGE_005.png"];
break;
default:
break;
}
如果圖像中出現的順序爲:1,4,2,5,4,3我怎麼能確保在直到顯示所有5張圖像後,「4」纔會再次出現?
感謝您的幫助!