我有一个UIScrollview
用于分页和缩放图像,当我在我的阵列中有一个图像时,它正在变焦,否则缩放会以奇怪的方式表现。分页很好。我有几天在苦苦挣扎,请帮助一下。我对UIScrollview
不熟悉。感谢。
-(void) settingScroll{
int xx,yy,im_xx,im_yy,im_Wt,im_ht;
CGRect screenRect = [[UIScreen mainScreen] bounds];
xx = screenRect.size.width;
yy = 452;
im_xx = 0;
im_yy = 0;
im_Wt = screenRect.size.width;
im_ht = 452;
scxx =0;
for(int i=0;i<[totalArray_menu count];i++)
{
scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(scxx, 0, xx, yy)];
[img2 setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",initial_server_address,[totalArray_menu objectAtIndex:i]]]];
img2.backgroundColor=[UIColor lightTextColor];
[scroll addSubview:img2];
[self.popUpImageScrollView2 addSubview: scroll];
scxx+=xx;
}
cntSizX=scxx;
self.popUpImageScrollView2.tag = 456;
self.popUpImageScrollView2.contentSize = CGSizeMake(cntSizX,yy);
self.popUpImageScrollView2.backgroundColor = [UIColor clearColor];
self.popUpImageScrollView2.pagingEnabled = YES;
self.popUpImageScrollView2.showsHorizontalScrollIndicator = NO;
self.popUpImageScrollView2.showsVerticalScrollIndicator = NO;
self.popUpImageScrollView2.bounces=YES;
scxx=xx;
[self.popUpImageScrollView2 setContentOffset:CGPointMake(scxx*tag,0) animated:NO];
[self.popUpImageView2 addSubview:self.popUpImageScrollView2];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return scroll;
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollV withView:(UIView *)view atScale:(double)scale
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
[self.popUpImageScrollView2 setContentSize:CGSizeMake(scale*screenRect.size.width, scale*452)];
}