黑马程序员技术交流社区
标题:
一个UIScrollView添加多个imageview不显示
[打印本页]
作者:
JevonLin
时间:
2015-11-8 11:03
标题:
一个UIScrollView添加多个imageview不显示
一个UIScrollView添加多个imageview不显示,代码如下:
UIScrollView *appScrollView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 275)];
appScrollView.contentSize=CGSizeMake(URLArray.count *appScrollView.frame.size.width /3, appScrollView.frame.size.height);
for(int i=0;i<[URLArray count];i++)
{
NSString *URLString=URLArray;
NSURL *url=[NSURL URLWithString:URLString];
NSData *imageData=[NSData dataWithContentsOfURL:url];
UIImage *image=[UIImage imageWithData:imageData];
UIImageView *imageView=[[UIImageView alloc] initWithImage:image];
//NSLog(@"%f",appScrollView.frame.size.width/3);
CGFloat imageViewX=i*appScrollView.frame.size.width/3;
CGFloat imageViewY=0;
CGFloat imageViewW=appScrollView.frame.size.width/3;
CGFloat imageViewH=appScrollView.frame.size.height;
imageView.frame=CGRectMake(imageViewX,imageViewY, imageViewW, imageViewH);
[appScrollView addSubview:imageView];
// NSLog(@"111");
}
appScrollView.pagingEnabled=YES;
appScrollView.delegate=self;
[self.view addSubview:appScrollView];
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2