ios - Image not shown on vertical-scrollView in a background horizontal-scrollView -
i show let's 3 long pictures (longer iphone's screen height) in big background uiscrollview
horizontally, , since each picture longer screen height, put 3 sub-uiscrollview
vertical swiping in background one.
i setup background 1 this:
_scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0, 0, screenwidth, screenheight)]; _scrollview.delegate = self; _scrollview.contentsize = cgsizemake(screenwidth*_count, screenheight); _scrollview.pagingenabled = yes; _scrollview.alwaysbouncevertical = no; _scrollview.alwaysbouncehorizontal = yes;
and setup each sub-uiscrollview
this:
if (imageheight > screenheight) { //requiring scrollview support uiimageview *longimgview = [[uiimageview alloc] init]; [longimgview setframe:cgrectmake(originx, 0, screenwidth, imageheight)]; longimgview.image = _image; uiscrollview *scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(originx, 0, screenwidth, screenheight)]; [scrollview setcontentsize:cgsizemake(screenwidth, imageheight)]; [scrollview setcontentoffset:cgpointmake(originx, 0)]; scrollview.backgroundcolor = [uicolor bluecolor]; scrollview.alwaysbouncevertical = yes; scrollview.alwaysbouncehorizontal = no; [scrollview addsubview:longimgview]; [_scrollview addsubview:scrollview]; }
please notice set scrollview.backgroundcolor = [uicolor bluecolor];
highlight sub-scrollview
, when run it, can see blue-colored sub-scrollview, cannot see picture showing (longimgview.image = _image;
).
update: can see memory address allocated _image
break point , console. can see sub-scrollview
has set same contentsize
image size cannot see image itself.
wait: [longimgview setframe:cgrectmake(originx, 0, screenwidth, imageheight)];
make that:
[longimgview setframe:cgrectmake(0, 0, screenwidth, imageheight)];
Comments
Post a Comment