私はSwiftのテーブルビューで動作するtodoリストアプリを開発しています。テーブルビューにはtitleLabelOutlet
というUILabelがあります。私は、アプリケーションを構築していたときに私はエラーが出てくるThe titleLabelOutlet outlet from the FirstViewController to the UILabel is invalid. Outlets cannot be connected to repeating content.
これまでにこのエラーを受け取ったことはありません。どうすれば修正できますか?ラベルは、セル 内部にあり、デリゲートでcrllfor行にあなたがその ようなあなたの店舗を取得する必要がありますので、あなたの店ではなくのViewControllerのセルクラスにする必要がありますVCからUILabelへのコンセントが無効です。アウトレットをリピートコンテンツに接続することはできません
import UIKit
var phoneNumberList = [String]()
var titleFieldList = [String]()
class FirstViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var titleLabelOutlet: UILabel!
@IBOutlet weak var phoneNumberLabelOutlet: UILabel!
@IBOutlet weak var myTableView: UITableView!
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return (phoneNumberList.count)
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "cell")
phoneNumberLabelOutlet.text = phoneNumberList[indexPath.row]
titleLabelOutlet.text = titleFieldList[indexPath.row]
return(cell)
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)
{
if editingStyle == UITableViewCellEditingStyle.delete
{
phoneNumberList.remove(at: indexPath.row)
titleFieldList.remove(at: indexPath.row)
myTableView.reloadData()
}
}
override func viewDidAppear(_ animated: Bool) {
myTableView.reloadData()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
可能な重複ができないため、今あなたがラベルの値を設定することができます繰り返しコンテンツiOSに接続](https://stackoverflow.com/questions/26561461/outlets-cannot-be-connected-to-repeating-content-ios) – dan