我正在尝试创建一个非常基本的图像库,其中包含三个图像,用户将能够滑过并查看图像。
我的解决方案正在使用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
于.