【问题标题】:The vcMenuLabel outlet from the ViewController to the UILabel is invalid. Outlets cannot be connected to repeating content从 ViewController 到 UILabel 的 vcMenuLabel 出口无效。插座无法连接到重复内容
【发布时间】:2021-03-15 10:01:39
【问题描述】:

我将UILabel放在UITableView的cell中,连接IBOutlet并构建,但是出现了错误。 这是一个错误。 “从 ViewController 到 UILabel 的 vcMenuLabel 出口无效。出口无法连接到重复内容。[12]” 我不知道解决办法,你能告诉我吗? Xcode12.2

import UIKit

class ViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSource, FSCalendarDelegateAppearance, UITableViewDataSource, UITableViewDelegate {
    
    @IBOutlet weak var noteTableView: UITableView!
    @IBOutlet weak var vcMenuLabel: UILabel!
    
    var vcMenuValue : String?
override func viewDidLoad() {
        super.viewDidLoad()
        
        vcMenuLabel.text = vcMenuValue
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
        let vcMenuLabel = UILabel(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 30))
        return cell
    }

【问题讨论】:

  • 你把标签放在tableView上面?你不希望它成为 tableView 的一部分吗?查看Interface builder,好像已经连接了很多次了。
  • 我将 UITableview 和 Cell 放在 Storyboard 上,并将 UILabel 放在上面。分割成xib文件?
  • 我不需要 Storyboard UILabel。非常感谢。

标签: ios swift xcode


【解决方案1】:

我通过删除 Storyboard UI Label 和 IBOutlet 解决了这个问题。

import UIKit

class ViewController: UIViewController, FSCalendarDelegate, FSCalendarDataSource, FSCalendarDelegateAppearance, UITableViewDataSource, UITableViewDelegate {
    
    @IBOutlet weak var noteTableView: UITableView!
    
    var vcMenuValue : String?

【讨论】:

    猜你喜欢
    • 2021-04-08
    • 2020-07-03
    • 2018-02-04
    • 1970-01-01
    • 1970-01-01
    • 2014-12-21
    • 2015-10-11
    • 2015-01-24
    相关资源
    最近更新 更多