iphone - Zoom only a selected subview from the UIScrollView -
i adding many uiimageview's uiscrollview,with paging enabled.i need zoom image have tapped zoom,rather zooming entire scrollview.also zooming particular image doesnot scale other subviews.
- (void)loadscrollviewwithimages { scrollview.contentsize = cgsizemake(self.view.bounds.size.width * imagelist.count, self.view.bounds.size.height); scrollview.pagingenabled = yes; uiview *mainview = [[uiview alloc] initwithframe:self.view.bounds]; cgfloat xpos = 0.0; (uiview *subview in scrollview.subviews) { [subview removefromsuperview]; } int = 0; (nsdictionary *imagedetails in self.imagelist) { uiimageview *imageview = [[uiimageview alloc] initwithframe:cgrectmake(xpos, 0.0, self.view.bounds.size.width, self.view.frame.size.height)]; imageview.contentmode = uiviewcontentmodescaleaspectfill; [imageview setclipstobounds:yes]; [mainview addsubview:imageview]; xpos += self.view.bounds.size.width; [imageview setimagewithurl:[nsurl urlwithstring:[imagedetails objectforkey:@"media_path"]]]; [self.imageviewarray addobject:imageview]; if(self.selectedimageindex == i) { self.selectedimageview = imageview; } i++; } [mainview setframe:cgrectmake(mainview.frame.origin.x, mainview.frame.origin.x,self.view.bounds.size.width * imagelist.count, self.view.bounds.size.height)]; [scrollview addsubview:mainview];
}
i wanted zoom selected index,but other subviews add screen no scaling.
- (uiview *)viewforzoominginscrollview:(uiscrollview *)scrollview { return [[[scrollview.subviews objectatindex:0] subviews] objectatindex:0] ;;
}
for implementing have take main scrollview have taken , instead of displaying imageview in scrollview have take scrollview , display image , when user tries zoom image selected scrollview gets scrolled.
Comments
Post a Comment