Xcode Error: Outlets cannot be connected to repeating content

早过忘川 提交于 2020-02-14 05:40:11

问题


After doing some searching and editing, I can't seem to find a solution to fixing this error. I'm trying to link my location search results with a table to display the search results in a list-form.

I have my map with the details button linked with a UIViewController called 'FirstViewController.' My results table is linked with a UITableViewController called 'ResultsTableViewController.' My prototype cells are linked with a UITableViewCell called 'ResultsTableCell' which is also where my outlets are located.

Here are the 2 separate errors:

Illegal Configuration: The nameLabel outlet from the ResultsTableViewController to the UILabel is invalid. Outlets cannot be connected to repeating content.

Illegal Configuration: The phoneLabel outlet from the ResultsTableViewController to the UILabel is invalid. Outlets cannot be connected to repeating content.

I've read other people's posts with the same problem, tried to fix them accordingly and I'm still getting the same error.

Here is the code for populating the cell, located in my ResultsTableViewController.

let cell = tableView.dequeueReusableCellWithIdentifier("resultCell", forIndexPath: indexPath) as! ResultsTableCell

    // Configure the cell...
    let row = indexPath.row
    let item = mapItems[row]
    cell.nameLabel.text = item.name
    cell.phoneLabel.text = item.phoneNumber
    return cell
}

The code in my ResultsTableCell class:

import UIKit

class ResultsTableCell: UITableViewCell {
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var phoneLabel: UILabel!
}

回答1:


This message only occurs if you connect it to the view controller. As I have already commented, you probably did not delete the first connection outlet you've made to your view controller. Even if you delete the IBOutlet code from your view controller you still need to right click it and delete the old connection that probably still there. After deleting it the error message will go away.




回答2:


this issue happen when you delete view from your class but still have reference in your view

here is example I remove back outlet reference from my class but my view still keep the reference Notice yellow rectangle just delete it by click at x

if you want to know how to reach this view , open your storyboard , right click at top left yellow it will show this dialog



来源:https://stackoverflow.com/questions/30008166/xcode-error-outlets-cannot-be-connected-to-repeating-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!