iOS: UIScrollView zooming programmatically not working -


i have pageable uiscrollview contains different kind of informations uitables zoomable images. therefore set pageable main-scrollview , subviews added zoomable image-scrollviews images content. works fine, fail set smaller current zoom scale of imagescrollviews.

uiimageview *imageview = [[uiimageview alloc] initwithimage:image];  //storing link imageview [imagelinkarray addobject:imageview];  cgrect scrollviewimagerect; scrollviewimagerect = cgrectmake((self.scrollview.frame.size.width) * i, 0, 320, self.scrollview.frame.size.height);  float widthfactor = scrollviewimagerect.size.width / imageview.frame.size.width; float heightfactor = scrollviewimagerect.size.height / imageview.frame.size.height; float zoomscale = min(widthfactor, heightfactor);  uiscrollview *imagescrollview = [[uiscrollview alloc] initwithframe:scrollviewimagerect]; imagescrollview.contentsize = cgsizemake(imageview.frame.size.width, imageview.frame.size.height);  imagescrollview.delegate = self;  [imagescrollview setminimumzoomscale:zoomscale]; [imagescrollview setmaximumzoomscale:1.5];  [imagescrollview addsubview:imageview];  //doesn't work: [imagescrollview setzoomscale:0.5 animated:yes];  [self.scrollview addsubview:imagescrollview];  - (uiview *)viewforzoominginscrollview:(uiscrollview *)scrollview {     return [imagelinkarray objectatindex:page]; } 

the main-scrollview , image-scrollviews drawn , it's possible zoom , page properly. minimum zoom factor calculated correct. when zoom out can zoom until image limits reached. first time page image-scrollview it's current zoom scale 1.0 while should minimum scale.

wherever set zoom scale in code above doesn't work:

[changescrollview setzoomscale:changescrollview.minimumzoomscale animated:yes]; 

if log current zoom scale 1.0;

the thing works changing zoom scale in - (void)scrollviewdidscroll: method, of course doesn't lot since zooming calls resets zoom immediately. @ least figure out, code somehow works. have feeling uiscrollview doesn't zoom when it's not visible on screen right now. how can fix this?

update: okay. in meantime figured out problem comes base layout of "sub-viewing" scrollviews scrollview. when zoom 1 of images , log current zoom factor of scrollviews same (main scrollview sub-scrollviews). reason or how solve different layout?

i think viewforzoominginscrollview: may not getting called scrollview. try add breakpoint , check you're returning there.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -