首页 文章

我如何修复“方法不会覆盖其超类中的任何方法 . ”?

提问于
浏览
4

override func tableView(tableView:UITableView,cellForRowAtIndexPath indexPath:NSIndexPath) - > UITableViewCell {

let cellIdentifier = "Cell"
    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! CustomTableViewCell

    // Configure the cell...
    cell.nameLabel.text = restaurantNames[indexPath.row]
    cell.thumbnailImageView.image = UIImage(named: restaurantImages[indexPath.row])
    cell.locationLabel.text = restaurantLocations[indexPath.row]
    cell.typeLabel.text = restaurantTypes[indexPath.row]

    cell.accessoryType = restaurantIsVisited[indexPath.row] ? .Checkmark : .None

    // Circular image
    cell.thumbnailImageView.layer.cornerRadius = cell.thumbnailImageView.frame.size.width / 2
    cell.thumbnailImageView.clipsToBounds = true

    return cell
}

2 回答

  • 1

    只需从 editActionsForRowAtIndexPathcommitEditingStyle 函数声明中删除 override 字即可 .

  • 5

    你应该分享你的全班 . 虽然,您似乎没有覆盖基类中的任何方法 . 从方法中删除 override 关键字,或者识别正确的BaseClass,其中存在具有相同签名(您想要覆盖的)的 Overridable 方法,然后正确使用 extends 关键字 .

    我认为你应该首先谷歌条款: MethodOverriding, BaseClass(or SuperClass)

相关问题