「ページ」ごとに1つの画像を含む、複数の画像を含むページングでUIScrollViewを作成しましたが、画像を互いに区別する方法があるかどうか疑問に思っていましたか? Fx。最初の画像が表示されているときは、UILabel を「1」に設定するボタンがあり、2 番目の画像が表示されているときは、同じボタンが同じ UILabel を「2」に設定します。
これが私のコードです:
pictures = [NSArray arrayWithObjects: [UIImage imageNamed:@"AND.png"], [UIImage imageNamed:@"ALB.png"], nil];
for (int i = 0; i < pictures.count; i++) {
CGRect frame;
frame.origin.x = 135 + (self.scrollViewQuiz.frame.size.width * i);
frame.origin.y = 40;
frame.size = CGSizeMake(50, 50);
UIImageView *subview = [[UIImageView alloc] initWithFrame:frame];
subview.image = [pictures objectAtIndex:i];
[self.scrollViewQuiz addSubview:subview];
}
self.scrollViewQuiz.contentSize = CGSizeMake(self.scrollViewQuiz.frame.size.width * pictures.count, self.scrollViewQuiz.frame.size.height);