我的应用程序中有一个UIscrollview,其中包含多个UIimageview。我想应用捏缩放/缩小功能。将UIImageview添加到UIScrollView的代码如下:
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
[scViewObject setCanCancelContentTouches:NO];
scViewObject.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scViewObject.clipsToBounds = NO; // default is NO, we want to restrict drawing within our scrollview
scViewObject.scrollEnabled = YES;
scViewObject.alwaysBounceHorizontal=YES;
scViewObject.pagingEnabled = YES;
UIView *view = nil;
NSArray *subviews = [scViewObject subviews];
for (view in subviews)
{
[view removeFromSuperview];
}
int left=20;
numberOfViewController=[ListOfImages count];
//NSMutableArray *controllers = [[NSMutableArray alloc] init];
for (unsigned ii = 0; ii < numberOfViewController; ii++)
{
UIImageView *temp=[[UIImageView alloc] init];
temp.contentMode=UIViewContentModeScaleAspectFit;
temp.userInteractionEnabled = YES;
temp.multipleTouchEnabled = YES;
temp.clipsToBounds = YES;
temp.image=[ListOfImages objectAtIndex:ii];
temp.frame=CGRectMake(left, 0, 280, 365);
temp.tag=ii;
[scViewObject addSubview:temp];
left=left+320;
}
[scViewObject setContentSize:CGSizeMake((numberOfViewController * kScrollObjWidth), 365)];
这里的scViewObject是UIscrollview。请建议我如何添加放大/缩小功能
答案 0 :(得分:1)
您需要观看几个ADC视频:
WWDC 2010:使用滚动视图设计应用
WWDC 2011:高级Scrollview技术
但基本上你需要在外部滚动视图的每个“页面”内部实现缩放滚动视图,并将每个图像添加到每个缩放滚动视图中。