ios - Relation between UICollectionView and layout object -


i new in ios , trying understand concept of uicollectionview. reading articles. article talk layout object. not understand relation between uicollectionview , layout object. please, can me understand concept. thanks.

uicollectionviewlayout

the uicollectionviewlayout class abstract base class subclass , use generate layout information collection view. job of layout object determine placement of cells, supplementary views, , decoration views inside collection view’s bounds , report information collection view when asked. collection view applies provided layout information corresponding views can presented onscreen.

this base class uicollectionviewflowlayout , uicollectionviewtransitionlayout. when initializing uicollectionview have specify layout want use of 2 mentioned above. if want normal flow layout instagram or uitableview, choose uicollectionviewflowlayout. if want have specialized behavior layout create interactive transitions, gesture recognizers or touch events implement behaviors when changing 1 layout in collection view, take uicollectionviewtransitionlayout.

in code:

uicollectionviewflowlayout *collectionlayout = [[uicollectionviewflowlayout alloc] init]; // or uicollectionviewtransitionlayout *collectionlayout = [[uicollectionviewtransitionlayout alloc] init];  uicollectionview *mycollectionview = [[uicollectionview alloc] initwithframe:cgrectmake(0, 0, 320, 480) collectionviewlayout:collectionlayout]; [mycollectionview setdelegate:self]; [mycollectionview setdatasource:self]; [mycollectionview registerclass:[uicollectionviewcell class] forcellwithreuseidentifier:cellidentifier]; [self.view addsubview:mycollectionview]; 

take note: .. collectionviewlayout:collectionlayout];

source


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -