我已经设置了一个 segue,它将显示一个带有小 TableView 的 View Controller 。我想要一个不同的 segue 来显示更大的 TableView,但我希望更大的表具有与较小的表相同的确切信息。让较小的 tableView 自己完美地工作,但是一旦我给较大的表一个数据源,重置并尝试它......崩溃。
//IndexPath 或 TableView 中的第一个单元格
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = UITableViewCell()
if self.TaskTableViews.hidden == false {
cell = tableView.dequeueReusableCellWithIdentifier( "FirstTask" , forIndexPath: indexPath) as UITableViewCell!
let list = frc.objectAtIndexPath(indexPath) as! List
cell.textLabel?.text = list.taskName
cell.textLabel?.textColor = UIColor.whiteColor()
TaskTableViews.backgroundColor = UIColor.lightGrayColor().colorWithAlphaComponent(0.55)
TaskTableViews.layer.cornerRadius = 8
TaskTableViews.separatorColor?.colorWithAlphaComponent(2.0) }
if self.TaskTable2.hidden == false {
cell = tableView.dequeueReusableCellWithIdentifier( "Second Task" , forIndexPath: indexPath) as UITableViewCell!
let list = frc.objectAtIndexPath(indexPath) as! List
cell.textLabel?.text = list.taskName
cell.textLabel?.textColor = UIColor.whiteColor()
TaskTable2.backgroundColor = UIColor.lightGrayColor().colorWithAlphaComponent(0.55)
TaskTable2.layer.cornerRadius = 8
TaskTable2.separatorColor?.colorWithAlphaComponent(2.0) }
return cell as UITableViewCell
}
最佳答案
问题是您的两个表的代码相互碰撞。要解决此问题,请重新调整您的逻辑。不要让你的逻辑依赖于隐藏的东西。您一次只能处理一张 table ;只有一张 table 在这里打电话。该表作为 tableView
参数出现。让你的逻辑依赖于那个。根据 tableView
参数是什么 TableView ,配置单元格并为该 TableView 返回它。
关于ios - 两个 TableView 一个数据源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35732914/