我需要獲取mtype的當前值並將其傳遞給Mselect,以便向前推送的圖像與動畫中旋轉的圖像相同。當我按下Xcode上的按鈕時,如何從數組循環中取出當前的整數值?
這裏是代碼示例
- (void)viewDidLoad
{
//Array to hold Images
NSMutableArray *imageArray = [[NSMutableArray alloc] initWithCapacity:Mush_Count];
for (mtype = 1; mtype < Mush_Count; mtype++)
{
[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"Mush%i.png", mtype]]];
//make button
SelectBt.imageView.animationImages = [NSArray arrayWithArray:imageArray];
SelectBt.imageView.animationDuration = 5;
[SelectBt.imageView startAnimating];
Mselect = mtype;
}
}
-(IBAction)Selection:(id)sender{
[self Placement];
}
-(void)Placement{
if (Place1Occ == NO) {
[self Place1];
}
}
-(void)Place1{
if (Place1Occ == NO) {
Place1.image =[UIImage imageNamed:[NSString stringWithFormat:@"Mush%i.png", Mselect]];
Place1Occ = YES;
}
}
動畫循環就好了,影像作品的選擇,但它不是選擇圖像目前是在屏幕上它選擇陣列上的最後一個影像。
有什麼建議嗎?
是mtype一個局部變量? Mselect呢? – insys
他們都是int,都是本地的,當我點擊時,我真的只需要mtype的值。因爲它通過圖像旋轉mtype = 1-9我需要該數字來爲我的UIImage視圖分配適當的值。 – Ramirez
出於某種原因,它給出了數組的最後一個值,最終分配數組中的最後一個圖像。無論何時按下按鈕。 – Ramirez