桌面视图中的Tableview swift
问题描述:
我需要有一个视图,其中有一个UITableView
和主要UITableView
有一个单元格具有另一个tableview。 我在故事板上添加了视图,并在单个视图控制器中实现了委托和数据源方法。 但实现代码如下方法没有得到所要求的内部实现代码如下,因为我已经设置内的tableview委托和数据源这样的:桌面视图中的Tableview swift
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = UITableViewCell()
switch tableView.tag {
case 1:
if indexPath.section == 0 {
let pendingReportsCell = tableView.dequeueReusableCellWithIdentifier("PendingReportsCell") as! PendingReportsTableViewCell
pendingReportsCell.taxYearTableView.delegate = self
pendingReportsCell.taxYearTableView.dataSource = self
taxTableView = pendingReportsCell.taxYearTableView
taxTableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: "EarliestMonthTaxYearCell")
tableView.tag = (taxTableView?.tag)!
taxTableView?.reloadData()
}
请告诉我一个备用做到这一点。
答
设置委托和数据源在您的自定义单元格类,如下: -
class PendingReportsCell: UITableViewCell {
// set the delegate & datasource of taxYearTableView in the init or
// awakefromnib or storyboard.
// I have set it in storyboard and it works for me.
// Implement the datasource and delegate methods of taxYearTableView in this class.
}
当taxTableView .reloadData()被调用时会调用上面的委托和数据源的方法
为什么需要表?在表格视图内查看? –
你想创建菜单?子菜单选项 –
用户界面设计是这样的,我需要另一个桌面视图。没有子视图在那里。只是一个tableview与2节。第一部分再次包含两个部分和数据。 – Roshni