在我的应用程序上,我需要将UIView添加到我的UITableViewController。现在,它只允许我将其添加到现有的表视图中。我想要的是将其添加到我的UITableViewController中。有人可以帮助我吗?谢谢!
您可以使用UIViewController,然后您将能够添加UITableView和UIView 。如果使用 UITableViewController,则无法在其中添加 UIView。
您可以通过编程方式执行此任务。
在viewDidLoad()
方法中添加此代码:
func setupBottomView() {
bottomView = BottomView(frame: .zero)
view.addSubview(bottomView)
bottomView.translatesAutoresizingMaskIntoConstraints = false
// Constraint Layout
NSLayoutConstraint.activate([
bottomView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0),
bottomView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 0),
bottomView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: 0),
bottomView.heightAnchor.constraint(equalToConstant: 120)
])
}