【发布时间】:2014-03-06 08:30:36
【问题描述】:
我有 10 个UIImages。当我单击UIButton 它显示在UIScrollView. But I need to implement theUIButtonlike **Next**, ifUIButtonis clicked first time, it displays the firstUIImage` 下,然后单击它会显示下一个图像。如果我点击后退按钮,应该会显示上一张图片。
int currentIndex = 0;
int MAX_COUNT;
NSMutableArray *imageName = [[NSMutableArray alloc] initWithObjects:
@"spices.jpg",
@"spice_powder.jpg",
@"turmeric.jpg",
@"whynani_img3.jpg",
@"spice_blends.jpg",
@"products1.png", nil];
currentIndex = currentIndex + 1;
if(currentIndex > MAX_COUNT) {
currentIndex = MAX_COUNT;
}
for (int i = 0; i<[imageName count]; i++ ) {
UIImageView *mmageView =
[[UIImageView alloc] initWithFrame:CGRectMake(200,200,350,350)];
[mmageView setImage:[UIImage imageNamed:[imageName objectAtIndex:i]]];
[self.view addSubview:mmageView];
}
【问题讨论】:
-
只需根据其索引制作图像数组并点击显示即可。
-
@HimanshuJoshi:你能帮我编辑一下代码吗?
标签: ios objective-c uiscrollview uibutton uiimage