在segue期间无法使用标识符对单元格出列

时间:2017-02-21 17:08:24

标签: swift xcode segue

当在桌子的单元格内按下按钮时,我正在执行segue。我有以下代码:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    if indexPath.row == self.selectedFriends.count {
        tableView.register(AddFriendsCell.self, forCellReuseIdentifier: "AddFriendsCell")
        let cell = tableView.dequeueReusableCell(withIdentifier: "AddFriendsCell", for: indexPath) as! AddFriendsCell
        cell.contentView.backgroundColor = colourBrandBrown
        cell.testButton.addTarget(self, action: #selector(FriendsVC.segueTest), for: .touchUpInside)

        return cell
    ...

“segueTest”代码是:

func segueTest() {

    print("TEST")
    self.performSegue(withIdentifier: "addFriends", sender: self)

}

当我按下按钮时,我得到了这个结果:

TEST
unable to dequeue a cell with identifier AddFriendsCell -
must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

您可以在代码中看到AddFriendsCell已注册,为什么会出现此错误?

0 个答案:

没有答案