无法在Xcode Playgrounds中初始化UICollectionView

时间:2018-03-15 08:57:28

标签: swift xcode uicollectionview swift-playground

我尝试初始化UICollectionView:

import UIKit
import PlaygroundSupport

let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))

但我得到的只是

error: Execution is interrupted, reason: signal SIGBART

1 个答案:

答案 0 :(得分:4)

要使用init(frame: CGRect, collectionViewLayout: UICollectionViewLayout)初始化UICollectionView,请检查Apple Doc:

let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 100, height: 100), collectionViewLayout: UICollectionViewFlowLayout())