这里我使用这段代码来查看数组中的下一个值,
-(IBAction)changenext
{
static int j = 0;
if (j >arcount)
{
j = 0;
}
lb1.text=[NSString stringWithFormat:[artext objectAtIndex:j]];
imager.image=[arimage objectAtIndex:j];
aplayer=[[AVAudioPlayer alloc]initWithData:[arsound objectAtIndex:j] error:nil];
j++;
}
如何通过其他按钮点击查看之前的数组值?请帮我解决..
最佳答案
-(IBAction)change_next_or_prev:(id)sender
{
static int j = 0;
if(sender == btnNext)
j++;
else if(sender == btnPrev)
j--;
if (j >= arcount)
{
j = 0;
}
else if(j < 0)
{
j = arcount - 1;
}
lb1.text=[NSString stringWithFormat:[artext objectAtIndex:j]];
imager.image=[arimage objectAtIndex:j];
aplayer=[[AVAudioPlayer alloc]initWithData:[arsound objectAtIndex:j] error:nil];
}
将两个按钮链接到相同的操作。
关于iphone - 如何在单击时查看以前的数组值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12948532/