CollectionView sizeForitemAt方法不适用于ios 9

时间:2017-12-13 06:22:17

标签: ios swift ipad uicollectionview

我遇到了奇怪的问题,我不知道为什么会发生这种情况。你可以看到这两张图片都是运行ipad的ios 9,另一张是运行ipad的ios11。对于运行ipad cell的ios9没有调整大小。我搜索了很多,但没有得到答案。请帮我这个,我也附上代码。 ios9 running Device ios11 running Device

 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! WalkthroughCollectionViewCell

    let walkObject = walkObjects[indexPath.row]

    cell.walkImageView.image = walkObject.image
    cell.walkHeader.text = walkObject.Header
    cell.walkDetails.text = walkObject.Details
    cell.getStartedButton.addTarget(self, action: #selector(getStarted(sender:)), for: .touchDown)

    if (indexPath.row + 1) == walkObjects.count {
        cell.getStartedButton.isHidden = false
    }else{
        cell.getStartedButton.isHidden = true
    }

    return cell
}


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


func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
    return 0.0
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
    return 0.0
} 

2 个答案:

答案 0 :(得分:16)

enter image description here

就我而言,我将 @method string image($dir = null, $width = 640, $height = 480, $category = null, $fullPath = true, $randomize = true, $word = null) test-images更改为.collapse span.fa-chevron-left { transform: rotate(90deg); transition: transform 0.25s ease-in-out; } .collapse.collapsed span.fa-chevron-left { transform: rotate(0deg); } ,并使用:

Estimate Size

答案 1 :(得分:0)

好的,我不知道为什么,但它现在正在工作。我只是设置NavigationBarHidden false。它开始工作了。