我需要一个视图,它有一个UITableView,而主 UITableView有一个单元格,它有另一个表视图。我在故事板上添加了视图,并在一个视图控制器中实现了委托和数据源方法。但是没有调用tableview方法,因为我已经设置了内部tableview委托和数据源,如下所示:
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()
}请告诉我另一个人来做这个。
发布于 2017-02-11 13:16:57
将自定义单元格类中的委托和数据源设置为:-
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()时,它将调用上述委托和数据源方法
https://stackoverflow.com/questions/42174838
复制相似问题