【发布时间】:2023-04-06 02:56:01
【问题描述】:
我正在尝试使用嵌入在 MainViewController 上的容器中的 UICollectionViewController
如下图:
这是我的 CollectionViewController:
class ExistingProjectsCollectionViewController: UICollectionViewController, UICollectionViewDelegate, UICollectionViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Register cell classes
self.collectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
}
// MARK: UICollectionViewDataSource
override func numberOfSectionsInCollectionView(collectionView: UICollectionView!) -> Int {
//#warning Incomplete method implementation -- Return the number of sections
return 1
}
override func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -> Int {
//#warning Incomplete method implementation -- Return the number of items in the section
return 1000
}
override func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as UICollectionViewCell
// Configure the cell
return cell
}
但是,由于某种原因,当我运行应用程序时,CollectionView 会滚动,但不包含橙色框。
我试过直接在 MasterViewController 上实现它, 效果很好 - 所以这似乎与使用 容器内的 UICollectionViewController。
我也试过关闭自动布局 - 没有成功。
我在 Xcode 6 Beta 6 上使用 Swift。
- 我已确保我的可重复使用的单元格 ID 在情节提要中是“单元格”
我错过了什么明显的东西吗?
【问题讨论】:
-
@matt 我的道歉,我的意思是 UICollectionViewController - 不是 UIContainerViewController
标签: ios uiviewcontroller swift uicollectionview containers