我想把UIView放在带有Sections的UITableView上面。
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(ActivityCell.self, forCellReuseIdentifier: "cellId")
//tableView?.contentInset = UIEdgeInsetsMake(70, 0, 0, 0)
objectArray = [Objects(sectionName: "sec 1", sectionObjects: ["sdqdsq", "sdsqdqsd", "dsqdsqd", "dsqqsdds"]),Objects(sectionName: "sec 2", sectionObjects: ["sdqdsq", "sdsqdqsd", "dsqdsqd", "dsqqsdds"]),Objects(sectionName: "sec 3", sectionObjects: ["sdqdsq", "sdsqdqsd", "dsqdsqd", "dsqqsdds"])]
setupProfilBar()
}
let profilBar: profilMenu = {
let pb = profilMenu()
pb.translatesAutoresizingMaskIntoConstraints = false
return pb
}()
func setupProfilBar() {
view.addSubview(profilBar)
profilBar.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
profilBar.heightAnchor.constraint(equalToConstant: 64).isActive = true
profilBar.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
}
我该如何解决这个问题?谢谢
答案 0 :(得分:0)
您希望将自定义视图设置为表格视图的tableHeaderView属性。没有必要像其他人提到的那样使用UIViewController而不是UITableViewController。 Here's the relevant Apple Documentation.
答案 1 :(得分:0)