ios - 无法为 UITableView 制作插座
问题描述
我试图在 UIViewController 中放置一个 tableview,但我无法控制从 UITableView 拖动到我的视图控制器中以创建一个插座。当我尝试拖动时,它拒绝提示插座。我什至尝试自己制作一个插座,然后从视图控制器类拖到表格视图,但它拒绝链接。
这是我的 Tableview 课程:
季节单元班
import UIKit
class SeasonCell: UITableViewCell {
@IBOutlet weak var seasonLabel: UILabel!
}
季节班
class Season: NSObject {
var name: String
init(name: String){
self.name = name
}
}
视图控制器
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var seasons = [Season]()
//created myself, wont link
@IBOutlet weak var seasonsTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
seasons.append(Season(name: "2018 Cross Country Season"))
seasonsTableView.delegate = self
seasonsTableView.dataSource = self
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return seasons.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "seasonCell", for: indexPath) as? SeasonCell
// Configure the cell...
let thisSeason = seasons[indexPath.row]
cell?.seasonLabel?.text = thisSeason.name
return cell!
}
}
解决方案
推荐阅读
- scala - 在 KStreams 中聚合实时数据
- java - 启动后定义的 Spring Boot DataSource
- c# - VS C# - Microsoft Excel 对象库参考
- fortran - fortran 中 H5_OpenGroup 和 H5Gcreate_f 命令的区别
- c++ - Windows XP 中来自 std::async 的 std::async
- linkedin - 使用 JS 获取 LinkedIn 数据 givs 错误“消息”:“未知身份验证方案”
- sql - 在数据库表中,根据一列值获取记录,该值基于其他两列
- c# - 同时更新窗口大小和网格边距
- excel - 粘贴数据 - Excel 的其他 Listobject 中的 Listobjects 范围
- c# - 按与一组字母匹配的第一个字母对列表进行排序