試試這個對imagesView顯示圖片....
UIImageView *imageView;
NSArray *arrayOfImage=[[NSArray alloc]initWithObjects:@"i1.jpg",@"i2.jpg",@"i3.png", nil];;
float x=10;
float y=50;
float width=100;
float height=100;
int i=0;
for(i=0;i<[arrayOfImage count];i++)
{
imageView=[[UIImageView alloc]initWithFrame:CGRectMake(x+width*i, y, width, height)];
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
}
else if(i==[arrayOfImage count])
{
i=0;
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i++;
}
,如果你想改變我的圖像在接下來的按鈕和後退按鈕...然後嘗試下面的代碼
- (IBAction)btnClicked:(id)sender
{
UIImageView *imageView;
NSArray *arrayOfImage=[[NSArray alloc]initWithObjects:@"i1.jpg",@"i2.jpg",@"i3.png",@"i1.jpg",@"i2.jpg",@"i3.png", nil];;
float x=100;
float y=100;
float width=100;
float height=100;
imageView=[[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];
if([sender tag]==0)
{
if(i<[arrayOfImage count])
{
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i++;
}
else if(i==[arrayOfImage count])
{
i=0;
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i++;
}
}else
{
if(i<[arrayOfImage count])
{
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i--;
}
else if(i==-1)
{
i=0;
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i++;
}
}
}
注:設置標籤用於下一步按鈕爲0,並設置標籤,以後退按鈕,當1
檢查我的答案。我想你有任何圖像陣列..然後寫下面的代碼。 –
你還沒有回覆。 –
等我檢查@Asoke Londhe – SoftCoder