ios - UIPageViewController Scroll transition affects webView content loading -
i have uipageviewcontroller contains 4 views. each of these views has next layout: each view can accessed initial view controller know pageviewcontroller.currentpage. each of these 4 views contains uiwebview loads it's html content in init method. uiwebviews width of view, 320. need them match height of given content, can scroll way downwards through content. works initial viewcontroller. sized webview in webviewdidload method so:
self.scrollview.clipstobounds = no; awebview.autoresizingmask = uiviewautoresizingflexiblebottommargin; //nslog(@"this webviewdidfinishload in action"); cgrect screenrect = [[uiscreen mainscreen] bounds]; cgfloat screenwidth = screenrect.size.width; cgrect frame = awebview.frame; frame.size.height = 1; awebview.frame = frame; cgsize fittingsize = [awebview sizethatfits:cgsizezero]; frame.size = fittingsize; awebview.frame = frame; scrollviewheight = scrollviewheight - self.articletitlelabel.frame.size.height; [self.scrollview setcontentsize:(cgsizemake(screenwidth, scrollviewheight))]; cgsize fullcontentsize = cgsizemake(screenwidth, scrollviewheight); [self.scrollview setcontentsize:fullcontentsize]; self.scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0,0,screenwidth, scrollviewheight)]; awebview.scrollview.scrollenabled= no; the problem when swipe viewcontroller, uiwebview not adequate height, , web content cutoff, , uiscrollview height of screen.
***exception: weird, may help reply question: if swipe horizontally initial viewcontroller appear , go other views, webviews load right height. problem still remains if load viewcontroller, , take time read content on page, swipe viewcontroller, webview cutting off.
i ended using solution 3 here , making scrollview fit views: uiwebview doesn't load completely, height varies
cgfloat height = [[awebview stringbyevaluatingjavascriptfromstring:@"document.height"] floatvalue]; cgfloat width = [[awebview stringbyevaluatingjavascriptfromstring:@"document.width"] floatvalue]; cgrect frame = awebview.frame; frame.size.height = height + 130.0; frame.size.width = width; awebview.frame = frame; //scrollview height views cgrect screenrect = [[uiscreen mainscreen] bounds]; cgfloat screenwidth = screenrect.size.width; self.scrollview.contentsize=cgsizemake(screenwidth, self.articleimgview.frame.size.height+self.articlecontentwebview.frame.size.height); ios objective-c uiwebview uiscrollview uipageviewcontroller
No comments:
Post a Comment