uiscroll ビューに遅延読み込みを実装する方法
Web サービスから 15 枚の画像を取得し、UIscrollview に追加します。スクロール ビューに一時的な画像を追加したいのですが、画像の準備ができたら、画像を uiscrollview に追加できます。
-(void)loadthscroll:(NSMutableArray *)idarray:(NSMutableArray *)imgarray
{
/*************scroll for scroll in in theater******************/
scrollview_intheater= [[UIScrollView alloc] initWithFrame:CGRectMake(0, btn_thhead.frame.size.height,view_banner.frame.size.width, view_intheater.frame.size.height-btn_thhead.frame.size.height)];
[view_intheater addSubview:scrollview_intheater];
[scrollview_thcsoon removeFromSuperview];
adj=5;
currentx=5;
for(int i=0;i<[imgarray count];i++)
{
btn_theater_ct = [UIButton buttonWithType:UIButtonTypeCustom];
btn_theater_ct.frame=CGRectMake(currentx, 5, 95, 120);
[btn_theater_ct addTarget:self action:@selector(theaterAction:) forControlEvents:UIControlEventTouchDown];
[scrollview_intheater addSubview:btn_theater_ct];
addr = [imgarray objectAtIndex:i];
addr = [addr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
//NSLog(@"addr-------%@",addr);
data_theater = [NSData dataWithContentsOfURL:[NSURL URLWithString:addr ] ];
[btn_theater_ct setBackgroundImage:[UIImage imageWithData:data_theater] forState:UIControlStateNormal];
currentx +=btn_theater_ct.frame.size.width+adj;
btn_theater_ct.tag=i;
[scrollview_intheater setContentSize:CGSizeMake(currentx,0)];
NSLog(@"add th scroll--%d----%d",[imgarray count],i);
}
}