3 つの画像を含む非常に基本的な画像ギャラリーを作成しようとしています。ユーザーは画像をスライドして表示できます。
私のソリューションはUIColor
NSArray *colors = [NSArray arrayWithObjects:[UIColor blueColor], [UIColor redColor], [UIColor greenColor], nil];
for (int i = 0; i < colors.count; i++) {
CGRect frame;
frame.origin.x = 320 * i;
frame.origin.y = 0;
frame.size = CGSizeMake(320, 208);
UIView *subview = [[UIView alloc] initWithFrame:frame];
subview.backgroundColor = [colors objectAtIndex:i];
[self.slideshow addSubview:subview];
}
self.slideshow.contentSize = CGSizeMake(320 * [colors count], 208);
しかし、画像は同様のソリューションでは表示されません
NSArray *images = [NSArray arrayWithObjects:[UIImage imageWithContentsOfFile:@"pic_1_3a.jpg"], [UIImage imageWithContentsOfFile:@"pic_1_3b.jpg"], [UIImage imageWithContentsOfFile:@"pic_1_3c.jpg"], nil];
for (int i = 0; i < images.count; i++) {
CGRect frame;
frame.origin.x = 320 * i;
frame.origin.y = 0;
frame.size = CGSizeMake(320, 208);
UIImageView *subview = [[UIImageView alloc] initWithFrame:frame];
subview.image = [images objectAtIndex:i];
[self.slideshow addSubview:subview];
}
self.slideshow.contentSize = CGSizeMake(320 * [images count], 208);
何か案が?は のUIScrollView
中に存在しUIView
ます。