0
如何在UICollectionViewCell中添加表格視圖?我不確定是否真的開始。我如何獲取表視圖數據源並委託出?這裏是我已經嘗試過...如何使用Swift在UICollection View Cell中添加表視圖?
我試過谷歌搜索它,但我得到的是如何在表視圖中添加集合視圖,而不是其他方式。
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
}