ios - How to make a tableview snap to cells centers ? (with gif animation illustration) -
the thing want achieve gallery, can contain 300 images, using uiscrollview result in non optimized ram/cpu usage since doesn't pooling (correct me if i'm wrong), , has limitation on width, can't make 300 times width of screen (again correct me if i'm wrong).
so right choice use uitableview  
1 - how make scroll horizontally in gif ?
2 - how make snap cells centers ?
edit
i'm using this, gives result want has problem, has no tolerance how should swipe move next cell, still need help..
func scrollviewdidenddragging(scrollview: uiscrollview, willdecelerate decelerate: bool) {     // find collectionview cell nearest center of collectionview     // arbitrarily start last cell (as default)     var closestcell : uicollectionviewcell = collectionview.visiblecells()[0];     cell in collectionview!.visiblecells() [uicollectionviewcell]     {         let closestcelldelta = abs(closestcell.center.x - collectionview.bounds.size.width/2.0)         let celldelta = abs(cell.center.x - collectionview.bounds.size.width/2.0)         if (celldelta < closestcelldelta)         {             closestcell = cell         }     }     let indexpath = collectionview.indexpathforcell(closestcell)     collectionview.scrolltoitematindexpath(indexpath!, atscrollposition: uicollectionviewscrollposition.centeredhorizontally, animated: true) }  func scrollviewwillbegindecelerating(scrollview: uiscrollview) {     // find collectionview cell nearest center of collectionview     // arbitrarily start last cell (as default)     var closestcell : uicollectionviewcell = collectionview.visiblecells()[0];     cell in collectionview!.visiblecells() [uicollectionviewcell]     {         let closestcelldelta = abs(closestcell.center.x - collectionview.bounds.size.width/2.0)         let celldelta = abs(cell.center.x - collectionview.bounds.size.width/2.0)         if (celldelta < closestcelldelta)         {             closestcell = cell         }     }     let indexpath = collectionview.indexpathforcell(closestcell)     collectionview.scrolltoitematindexpath(indexpath!, atscrollposition: uicollectionviewscrollposition.centeredhorizontally, animated: true) }   edit :-
i managed without above code.
you should use uicollectionview 1 cell or uipageviewcontroller achieve kind of effect. there no way use tableview horizontally. somehow can uicollectionview horizontal representation of uitableview. uipageviewcontroller solution. should read both in detail , decide what's more suitable you!
and yes that's not use single scroll view different size. can create memory or performance issue!!
update :
have tried enable paging in collection view's scroll view ?
look @ screenshot below
check checkbox paging enable!
then after if not feel smooth effect should try uncheck adjust scroll view insets under viewcontroller under attribute inspector got selecting view controller
check screenshot that
edit person asked question : -
adding worked me, uicollectionview don't have  adjust scroll view insets option.
layout.minimuminteritemspacing = 0 layout.minimumlinespacing = 0   


Comments
Post a Comment