0

ここでは、このコードを使用して配列内の次の値を表示しました。

-(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++;
}

他のボタンをクリックして以前の配列値を表示するにはどうすればよいですか?解決するのを手伝ってください..

4

2 に答える 2

2
-(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];
}

両方のボタンを同じアクションにリンクします。

于 2012-10-18T06:45:16.930 に答える
0
-(IBAction)changeprev
{
static int j = arcount;
if (j < 0)
{
   j = arcount;
}
 lb1.text=[NSString stringWithFormat:[artext objectAtIndex:j]];
 imager.image=[arimage objectAtIndex:j];
 aplayer=[[AVAudioPlayer alloc]initWithData:[arsound objectAtIndex:j] error:nil];

j--;
}
于 2012-10-18T06:39:45.637 に答える