【发布时间】:2015-06-03 22:50:01
【问题描述】:
如何在 UICollectionViewCell 中添加表格视图?我不确定真的要开始。如何获取表视图数据源并委派出去?这是我已经尝试过的......
我试过谷歌搜索它,但我得到的只是如何在表格视图中添加集合视图,而不是相反。
import UIKit
class GeneralAisleViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var collectionView: UICollectionView!
var tableView:UITableView = UITableView()
var CollectionViewArray = ["1", "2", "3"]
var tableView1Array = ["1", "2"]
var tableView2Array = ["1", "2"]
var tableView3Array = ["1", "2"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.collectionView.delegate = self
self.collectionView.dataSource = self
self.tableView.delegate = self
self.tableView.dataSource = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return CollectionViewArray.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell:UICollectionViewCell = self.collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! UICollectionViewCell
let dataToDisplay:String = CollectionViewArray[indexPath.row]
let dataLabel:UILabel = cell.viewWithTag(1) as! UILabel
dataLabel.text = dataToDisplay
let TableView = cell.viewWithTag(2) as! UITableView
self.tableView = TableView
return cell
}
【问题讨论】:
标签: ios uitableview swift ios8 uicollectionview