ios - In my app I used uicollectionview then how to make difference between two cell same in all iPhone models? -
in app used uicollectionview how make difference between 2 cell same in iphone models. , auto layout turned on tried many things issue not resolved app looks perfect in iphone 5s shows more difference between 2 cells in iphone 6s , 6s plus.enter image description here
you need calculate cell dynamically according screen size. have faced such situation , fixed it. can try this, might you...
- (cgsize)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout*)collectionviewlayout sizeforitematindexpath:(nsindexpath *)indexpath { return cgsizemake(width, height); }
get width , height
-(void)getdynamiccellsize { width = (screen_size.width - 50)/3; height = (screen_size.height - (135+self.tabbarcontroller.tabbar.frame.size.height)-29)/3; } // 135 means navigation bar height + segment control (i have in design) cgfloat width, height;// declare globally
call getdynamiccellsize method in viewwillappear or didload
or
use code in sizeforitematindexpath method in 'swift'
let flowlayout = collectionviewlayout as! uicollectionviewflowlayout let cellwidth = (cgrectgetwidth(collectionview.frame) - (flowlayout.sectioninset.left + flowlayout.sectioninset.right) - flowlayout.minimuminteritemspacing) / 2 return cgsize(width: cellwidth, height: cellwidth)
happy coding...
Comments
Post a Comment