2016-08-01 98 views
0

嘿,大家我在這裏有一些問題,我會盡我所能地盡力解釋。所以我有一個集合視圖,其中包含一個集合視圖單元格,並且該單元格內嵌入的是一個表格視圖,並且在該表格視圖中,我希望返回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 

} 

回答

0

使用xib或故事板向單元格添加tableviews。並將所有這些委託和tableview的數據源放入collectionviewcell類中,並告訴tableviews其數據源和委託在這個類中。讓我知道這是否有效。

相關問題