相关疑难解决方法(0)

UITableViewCOntroller中的swift多个单元格子类

我正在尝试将多个子类添加到UITableView中.问题是它一直给我以下错误:

Type UITableVieCell does not conform to protocol NilLiteralConvertible
Run Code Online (Sandbox Code Playgroud)

的cellForRowAtIndexPath

override  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    if indexPath.section == 0 {

        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell

        cell.textLabel?.text = self.section1[indexPath.row]
        cell.accessoryType = .DisclosureIndicator

        return cell

    } else if indexPath.section == 1 {

        let cell = tableView.dequeueReusableCellWithIdentifier("SwitchViewCell", forIndexPath: indexPath) as SwitchViewCell

        cell.cellLabel?.text = self.section2[indexPath.row]

        return cell
    }

    return nil
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview ios swift

7
推荐指数
3
解决办法
1万
查看次数

标签 统计

ios ×1

iphone ×1

objective-c ×1

swift ×1

uitableview ×1