adding a UITableView programmatically to a UIViewController

前端 未结 5 1314
栀梦
栀梦 2021-02-02 17:37

I\'m loading a UIViewController into one of my Nav controller\'s hierarchies, which will contain some text and some images. At the bottom, I will want to create a expandable and

5条回答
  •  不知归路
    2021-02-02 18:24

    Yes, you can create a UITableView whose delegate, datasource, and parent view are not necessarily a UITableViewController. Since the UITableView is a UIView, you can add it as a subview of any other UIView. Any NSObject can be the delegate or datasource, as long as you implement the required protocol methods.

    @interface MyViewController : UIViewController  
    

    In fact, in my experience, not many people even use UITableViewControllers. When was the last time you wanted your table view to take up the entire usable space? In general, I create a plain old UIViewController and add a UITableView as a subview of its view, in addition to other subviews.

提交回复
热议问题