ios - ScrollView With AutoLayout -
ios - ScrollView With AutoLayout -
i have weird output autolayout used next scenario.
i have 4 sub pages scroll. (subpage or scrollpage has been designed separately autolayout).
mainview has scrollview component loads sub pages.
everything fine except starting. after first load, sub page components not arranged properly. receives first tap/touch, automatically re-scrolls/re-arranges proper places. looks bug.
the loading creates problem. have attached 2 images reference above scenarios. firstone @ first loading
second 1 after tapping on scroll area
second 1 proper one. need show instead of first. need help prepare this.
thanks, satyaranjan
one more thing note, [myscroll scrollrecttovisible:cgrectmake(320*pagenumber, 0, 320 , 240) animated:no]; not working using dynamic width subpage. because vary iphon5 , iphone6
first, don't want set scrollview's contentsize when using autolayout -- if sub views laid out correctly, automatically.
try this:
constrain 4 of scrollview's edges parent make sure translatesautoresizingmaskintoconstraints no views create view called "contentview" , parent scrollview. pin 4 of contentviews's edges scrollview parent subviews contentview , arrange them autolayoutif reason need alter size of subview programmaticly, need override intrinsiccontentsize method homecoming right size after change. after change, might need phone call view's sizetofit method parent view (not sure -- may happen automatically).
in general, when using autolayout, should never explicitly set size of anything. if can't avoided, should creating height/width constraints , modifying them @ runtime in updateconstraints method.
edit:
i made illustration project demonstrates how set scrollview , couple other things.
take look!
https://github.com/annabd351/autolayouttemplate
ios objective-c ios7
Comments
Post a Comment