jay*_*tel 5 ipad ios uicollectionview swift
我遇到了奇怪的问题,我不确定为什么会发生这种情况。正如您所看到的,这两个图像一个是运行 ipad 的 ios 9,另一个是运行 ipad 的 ios11。对于运行 ipad 的 ios9,单元格未调整大小。我搜索了很多,但没有得到答案。请帮我解决这个问题,我还附上了代码。


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
}
Run Code Online (Sandbox Code Playgroud)
Sen*_*ian 23
就我而言,我Estimate Size从Automatic改为None并使用:
collectionView(_ collectionView: UICollectionView, layout
collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath:
IndexPath) -> CGSize
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2653 次 |
| 最近记录: |