【发布时间】:2016-08-01 02:56:59
【问题描述】:
大家好,我在这里遇到了一些问题,我会尽量解释清楚。所以我有一个带有集合视图单元格的集合视图,并且嵌入在该单元格中的是一个表格视图,并且我想使用该表格视图返回 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
}
【问题讨论】:
标签: ios uitableview uicollectionview