How to add a UIView above the current UITableViewController

后端 未结 20 797
旧时难觅i
旧时难觅i 2020-11-27 11:57

I have difficulty adding a subview (UIView) from within the viewDidLoad method of a UITableViewController

This works:

[self.view addSubview:self.prog         


        
20条回答
  •  一生所求
    2020-11-27 12:35

    I tried the approach above, but did not get it to work. I also found it to require too much configuration and code, since it requires setting up the table view from scratch (something that is easily done from within the storyboard).

    Instead, I added the view that I wanted to add above my UITableView into the UITableViewController's UINavigationController's view, as such:

    [self.navigationController.view addSubview:];
    

    This approach requires that you have embedded the UITableViewController in a UINavigationController, but even if you do not want a navigation controller, you can still use this approach and just hide the navigation bar.

提交回复
热议问题