简体   繁体   中英

UICollectionViewCell has a not the same size on iOS7 and iOS 8

I'm building a UICollectionView where each cell has size of 159x159. When the app runs on ios8 it gives (whatever the simulator i choose : iPhone 4S, 5, 5S, 6, 6 Plus) :

使用iOS 8.3的iPhone Simulator上

But it has not the same size on iOS7 :

使用iOS 7.1的iPhone Simulator上

WTF ? Note that even my SearchBar has not the same width on both simulators.

The reason for this is that iOS8 has layout margins whilst iOS7 does not. You have made your constraints of the views to the margins.

The way I would facilitate it is if you want it to look like the iOS8 version in both, then don't constrain the views to the margins, but to the edges themselves, and have a constant space between the views and the edges. If you are using storyboards for the auto layout, then you will notice you can tick either on or off if to constrain to margins or not.

边距约束

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM