【发布时间】:2015-05-03 14:08:50
【问题描述】:
我正在尝试使用 UICollectionViews 获得七个水平滚动按钮栏。启动并运行一个按钮栏没有问题,但是当我使用多个集合视图时遇到应用程序崩溃错误。有人知道如何在 Swift 中实现这一点或知道任何教程吗?我的第一个 Collection View 的代码在这里:
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
var tableImages: [String] = ["1.png", "2.png", "3.png", "4.png", "5.png", "6.png"]
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return tableImages.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell:CollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CollectionViewCell
cell.expansionCell.image = UIImage(named: tableImages[indexPath.row])
return cell
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
println("cell \(indexPath.row) selected")
}
}
请帮忙!
【问题讨论】:
-
您遇到了什么错误?在哪条线上?
-
有很多教程把UICollectionView放在UITableViewCell中,所以制作一个包含UICollectionView的UITableView,在UITableView中可以得到多个UICollectionView,ashfurrow.com/blog/…
-
我收到线程 1 信号 SIGABRT。
-
您在哪一行收到该错误?
-
从这里开始:developer.apple.com/library/ios/recipes/…。这是一个没有错误解释的非问题。
标签: ios iphone swift uicollectionview