简体   繁体   中英

UICollectionView Cell resizing issue

I am new to iOS app development and I am trying to understand what is the issue in iPhone 11 Pro Simulator of my layout when works well in iPhone 8 Plus.

Please find the screenshot below:

在此处输入图片说明

Can anyone help me out on why this is happening?

If you require anymore information on the code, Please let me know.

EDIT:

This is my CollectionView Attributes:

在此处输入图片说明

It appears that the cell is little zoomed in when it comes to the iPhone 11 Simulator.

You must have to implement Size for item method and need to confirm to UICollectionViewDelegateFlowLayout .

As every iPhone has different width you can not set to static width.

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: collectionView.frame.width, height: 150)
    }

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