ios - scrollToItemAtIndexPath before the view is shown the first time -


i have uiview added uicollectionview. view shown on app start up. @ same time i'm scrolling position in collection view. therefore use scrolltoitematindexpath. problem scrolls wrong position, because collection view has wrong size @ beginning: if start ipad in landscape orientation on ios 7 collection view takes 768 width despite in landscape.

how can scroll position without user noticing it? in view hierarchy can call it?

viewwillappear: frames have not been set
viewdidappear: not possible without user noticing it
layoutsubviews: called multiple times , need @ startup , when user presses button

i tried use layoutifneeded, doesn't edge case (ios 7, ipad, landscape @ startup).

constraints kick around time viewdidappear , layoutsubviews called last time. time it's late.

you can try inheriting own class uicollectionview , see if layoutsubviews has correct constraints , call scrolltoindex there.

if fails, can cheat setting frame sizes in viewdidload , calling scroll index. ( 1 tad bit more complicated) –


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -