【发布时间】:2015-07-01 06:52:42
【问题描述】:
我在两个UITableViews 上方有一个分段控件,其中一个位于另一个之上。当segmentedControl.selectedSegmentIndex == 1 时,其中一个表视图将隐藏。然而,问题是我无法在我的一个cellForRowAtIndexPath 函数中配置第二个表格视图的自定义单元格。我不断收到:Variable 'cell' used before being initialized。
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch segmentedControl.selectedSegmentIndex {
case 0:
var cell = tableView.dequeueReusableCellWithIdentifier("CellOne", forIndexPath: indexPath) as! CellOne
return cell
case 1:
var cellTwo = tableView.dequeueReusableCellWithIdentifier("CellTwo", forIndexPath: indexPath) as! CellTwo
return cellTwo
default:
var cell: UITableViewCell
return cell
}
}
【问题讨论】:
标签: ios swift uitableview uisegmentedcontrol