【发布时间】: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。非常感谢。