「The titleLabel outlet from the UIViewController to the UILabel is invalid. Outlets cannot be connected to repeating content. 」というエラーが出続けています。一度大文字と小文字のミス等をした事でエラーが出たことはわかったので、結びつけ直すなどしたのですが消えません。
原因がお分かりになる方がいらっしゃいましたら、教えていただけますと幸いです。
[補足]
見落としがあるかもしれませんが、Storyboardのラベルも含めて修正しました。
Outlet削除と名前の変更、またStoryboard上で変更後の結びつき以外がないことを確認しました。
UILabelの部分で右クリックをして、titleLabelという名前のものがないことを確認したのですが、エラーメッセージは変わらずに出続けている状況です。
Outlet削除後のメッセージ
「The titleLabel outlet from the UIViewController to the UILabel is invalid. Outlets cannot be connected to repeating content. 」
回答をいただく前に一度確認しtitleLabelを削除して、現在画像のような状態です。
swift
1コード 2import UIKit 3 4class FloorViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 5 6 7 8 @IBOutlet weak var tbl: UITableView! 9 10 let titleList = ["玄関", "キッチン", "洗面", "トイレ", "浴室", 11 "洗濯", "エアコン", "居室", "ベランダ", "その他①", 12 "その他②", "その他③"] 13 14 override func viewDidLoad() { 15 super.viewDidLoad() 16 17 self.tbl.delegate = self 18 self.tbl.dataSource = self 19 // Do any additional setup after loading the view. 20 } 21 22 func numberOfSections(in tableView: UITableView) -> Int { 23 return 1 24 } 25 26 // セル数 27 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 28 return self.titleList.count 29 } 30 31 // セル内容 32 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 33 let cell = tableView.dequeueReusableCell(withIdentifier: "TitleCell") as! TitleTableViewCell 34 35 36 cell.TitleLabel.text = self.titleList[indexPath.row] 37 return cell 38 } 39 40 // MARK: UITableViewDelegate 41 42 // セルタップ時の処理 43 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 44 45 // タップ時の処理を記述 46 47 } 48 49 override func didReceiveMemoryWarning() { 50 super.didReceiveMemoryWarning() 51 // Dispose of any resources that can be recreated. 52 } 53}
swift
1コード 2import UIKit 3 4class TitleTableViewCell: UITableViewCell { 5 @IBOutlet weak var TitleLabel: UILabel! 6 7 override func awakeFromNib() { 8 super.awakeFromNib() 9 // Initialization code 10 } 11 12 override func setSelected(_ selected: Bool, animated: Bool) { 13 super.setSelected(selected, animated: animated) 14 15 // Configure the view for the selected state 16 } 17 18}
回答2件
あなたの回答
tips
プレビュー