一个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];
|
|