harshit padaliya harshit padaliya - 3 months ago 11
Objective-C Question

In my app I used uicollectionview then how to make difference between two cell same in all iPhone models?

In my app I used uicollectionview then how to make difference between two cell same in all iPhone models. and auto layout is turned on I tried many things but issue is not resolved my app looks perfect in iPhone 5s but It shows more difference between two cells in iPhone 6s and 6s plus.enter image description here

Answer

You need to calculate the cell dynamically according to the screen size. I have faced such situation and fixed it. You can try this, might be help you...

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(width, height);
}

get width and height

-(void)getDynamicCellSize {

width = (SCREEN_SIZE.width - 50)/3;
height = (SCREEN_SIZE.height - (135+self.tabBarController.tabBar.frame.size.height)-29)/3;
} // 135 means the navigation bar height + segment control (I have in my design) 

CGFloat width, height;// Declare globally

Call getDynamicCellSize method in viewWillAppear or didLoad

Happy coding...