iphone - 如何在单击时查看以前的数组值

标签 iphone ios uibutton nsmutablearray

这里我使用这段代码来查看数组中的下一个值,

-(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/

相关文章:

iphone - 从未调用过 LocationManager 的 didEnterRegion

iPhone:以编程方式打开 URL

ios - Objective-C : Infinite getter method loop after converting to ARC

ios - 如何在单元格中的按钮上添加横幅通知

iphone - UITableViewvisibleCells(在部分?)

iPhone Web 服务和表格 View

ios - Swift: Extension,通过这个函数的所有路径都会调用自己

ios - 无法使用以下代码更新记录

ios - 在发件人中使用带有 UIButton 的标签属性并尝试转换 id -> UIButton

iphone - 数字键盘在完成显示时丢失自定义 UIButton 的奇怪问题