ios - Zooming in UIScrollView - Unable to zoom beyond single image and scroll -
i have array of images loading nsurl scroll in , pinch zoom. able implement scroll part when try zoom image beyond first one, scroll stuck , scale on image. here code:
scrollview = [[uiscrollview alloc]initwithframe:cgrectmake(0, 100, screen_width, self.view.bounds.size.height)]; scrollview.showshorizontalscrollindicator = false; scrollview.maximumzoomscale = 4.0; scrollview.minimumzoomscale = 1.0; scrollview.delegate = self; [self.view addsubview:scrollview]; (int i=0; i<[listofimageszoom count]; i++) { imageview = [[uiimageview alloc] initwithframe:cgrectmake(leftmargin, self.scrollview.bounds.origin.y-100, screen_width, self.view.bounds.size.height-100)]; // [imageview setimage:[uiimage imagenamed:@"img_def.png"]]; nsstring *urlimage1 = (nsstring*)[listofimageszoom objectatindex:i]; nsstring *productimageurl1 = [urlimage1 stringbyreplacingoccurrencesofstring:@"~" withstring:@""]; nsstring *productimageurl2 = [productimageurl1 stringbyreplacingoccurrencesofstring:@" " withstring:@"%20"]; nsstring* urlimage = [nsstring stringwithformat:@"http://sagana-ideas.azurewebsites.net%@", productimageurl2]; nsurl *imgurl=[nsurl urlwithstring:urlimage]; [imageview setimagewithurl:imgurl placeholderimage:[uiimage imagenamed:@"ex_product.png"]]; imageview.contentmode = uiviewcontentmodescaleaspectfit; [scrollview addsubview:imageview]; [imageview setuserinteractionenabled:no]; imageview.tag = i; leftmargin += screen_width; } [scrollview setcontentsize:cgsizemake(leftmargin, 0)]; [scrollview setpagingenabled:yes]; scrollview.delegate = self;
i have implemented
- (uiview *)viewforzoominginscrollview:(uiscrollview *)scrollview { return imageview; }
it works if there single image load, stuck when there more 1 image.
you need scrollview display list of images. each image displayed scrollview(a subclass scrollview) perform zoom in/out. try @ this: mwphotobrowser
Comments
Post a Comment