2017-02-11 28 views
0

我需要有一個視圖,其中有一個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() 
} 

請告訴我一個備用做到這一點。

+0

爲什麼需要表?在表格視圖內查看? –

+0

你想創建菜單?子菜單選項 –

+0

用戶界面設計是這樣的,我需要另一個桌面視圖。沒有子視圖在那裏。只是一個tableview與2節。第一部分再次包含兩個部分和數據。 – Roshni

回答

0

設置委託和數據源在您的自定義單元格類,如下: -

 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()被調用時會調用上面的委託和數據源的方法