我有一個UIImageView *picture
更改圖像使用按鈕iPhone
和UIButton *next
和
- (IBAction)next {
}
我想改變的觀點,但只有當圖像等於圖像...例如img1
但使用相同的按鈕我想也能夠改變圖片,如果圖像= img2,但不同的圖像(img3)
到目前爲止,我有這樣的代碼,但它給我的錯誤:
- (IBAction)next {
if (picture UIImage = imageNamed:@"img01.jpg") {
[picture setImage: [UIImage imageNamed:@"img02.jpg"
}
if (picture UIImage = imageNamed:@"img02.jpg") {
[picture setImage: [UIImage imageNamed:@"img03.jpg"
}
}
除非你有迫切的需求,否則你不應該使用靜態變量。你現在沒有辦法獲得圖像索引。 – mvds 2010-08-01 13:13:03