单个集合视图单元格内的控制表视图
问题描述:
嘿,大家我在这里有一些问题,我会尽我所能地尽力解释。所以我有一个集合视图,其中包含一个集合视图单元格,并且该单元格内嵌入的是一个表格视图,并且在该表格视图中,我希望返回3(用于未来测试更多)单元格,这将返回3个表格视图。有了这些表格我想要有不同类型的数据,但我想知道我可以如何做到这一点,或者如果可能的话,我的故事板中只有一个表格视图。我已经试图尝试这个,但所有事情都以零为单位返回。提前致谢!单个集合视图单元格内的控制表视图
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
if tableView == tableview1 {
return 0;
} else if tableView == tableview2 {
return 3
}
return 0;
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
if tableView == tableview1 {
return 2;
} else if tableView == tableview2 {
return 1;
}
return 0;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
if tableView == tableview1 {
cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
} else if tableView == tableview2 {
cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
}
// Configure the cell...
if tableView == tableview1 {
cell.textLabel?.text = "Homeroom"
cell.detailTextLabel?.text = "8:15 AM - 9:00 AM"
cell.selectionStyle = .None
} else if tableView == tableview2 {
cell.textLabel?.text = "Test Table 2 "
cell.detailTextLabel?.text = "1:30 PM - 2:30 PM"
cell.selectionStyle = .None
}
return cell
}
答
使用xib或故事板向单元格添加tableviews。并将所有这些委托和tableview的数据源放入collectionviewcell类中,并告诉tableviews其数据源和委托在这个类中。让我知道这是否有效。