ios - UIWebView apparently scrolled after loading content from URL -
i loading html document uiwebview loadrequest:requesturl. html content not fit entirely view's frame. surprises me @ time page has been loaded (when webviewdidfinishload:is called) view's scrollview.contentoffset different (0,0). looks if content may have been scrolled down approximately vertical center aligned view's vertical center (see screenshot below).
how can happen , how can achieve desired behavior of having content's top left corner aligned view's top left corner initially? setting scrollview.contentoffset (0,0) in webviewdidfinishload:` option apparently leads flickering.
this occurring in context of uiviewcontroller contains 2 sibling uiwebviews below root view. 2 uiwebviews vertically stacked uilabel (appears in screenshot gray background) in between. (the lower uiwebview not visible in screenshot, because it's white.) view uses constraint-based layout , current problem concerns upper uiwebview.
update further study has revealed visual defect not due scrolling in upper uiwebview due frame.origin.y having been set 0 64 (which combined height of status bar , navigation bar) time webviewdidfinishload called. calling loadrequest:requestwithurl: view controller's viewwillappear: , there layout constraint on upper uiwebview imposes vertical space of 0 between top , bottom of top layout guide.

i think happens following: ios 7 wants uiscrollviews extend underneath status , navigation bars when scrolled downwards. apparently performs initial vertical scrolling means preventing top part of web content being hidden behind these bars before scrolling occurs.
i had layout constraint vertical distance of 0 top layout guide placed on uiwebview led wrong vertical distance of twice height of status bar plus height navigation bar top of screen. replacing layout constraint 1 vertical distance of 0 superview corrected wrong.
Comments
Post a Comment