【发布时间】:2013-11-21 09:26:13
【问题描述】:
我需要在滚动视图中多次添加图像。我创建了一个滚动视图,但图像未正确附加。
我的代码在这里:
-(void)sampleScroll
{
int x = 10;
int y = 20;
mainScrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
mainScrollView.contentSize = CGSizeMake(50, (y + 95) * 5);
// further configure
[self.view addSubview: mainScrollView];
images = [[NSMutableArray alloc] initWithObjects:@"image0.jpg",@"image1.jpg",@"image2.jpg",@"image3.jpg", nil];
for(int i=0; i<[images count]; i++)
{
NSLog(@"%@",images);
UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(x, y, 250, 150)];
scrollview.showsVerticalScrollIndicator=YES;
scrollview.scrollEnabled=YES;
scrollview.userInteractionEnabled=YES;
scrollview.backgroundColor = [UIColor whiteColor];
NSString *img = [images objectAtIndex:i];
NSLog(@"%@",img);
imageView.image = [UIImage imageNamed:@"image3.jpg"];
NSLog(@"%@",imageView.image);
scrollview.contentSize = CGSizeMake(1250,250);
[scrollview addSubview:imageView];
[mainScrollView addSubview:scrollview];
y=y+155;
//[self myscrollView];
}
}
请给我一个解决方案。提前谢谢..
【问题讨论】:
-
我需要创建图片库..
-
改用 UICollectionView。
标签: ios iphone ios5 ios6 uiscrollview