How to link Table dataSource and delegate outlets to UITableViewController?

后端 未结 3 997
挽巷
挽巷 2021-01-05 09:40

I\'m new to Swift/iOS development.

I have a UITableView in my storyboard that I want to populate with some data. In my attempt to do so, I

相关标签:
3条回答
  • 2021-01-05 09:59

    Set your viewController to inherit from UIViewController, not from UITableViewController (It seems like your IB is set up like that). Do not forget to set your class to ZeroconfTableController on the interface builder.

    Than, you will be able to set the delegate and datasource. NOTE: the delegate and the datasource will not create IBOutlets.

    Assign the delegate and the dataSource the following way:

    Also make sure, your viewController conforms to the protocols.

    class ZeroconfTableController: UIViewController, UITableViewDataSource, UITableViewDelegate { 
    
    0 讨论(0)
  • 2021-01-05 10:06

    In your storyboard, select the UITableView and change this to the name of your UITableViewController subclass. You then do not need to do any linking stuff.

    0 讨论(0)
  • 2021-01-05 10:16

    If you're using your own UITableView, inherit from UIViewController, not UITableViewController.

    If however, you want to use a UITableViewController (which personally I don't use) in your storyboard, then do inherit from UITableViewController. In this case you won't have to wire up the UITableViewDataSource nor the UITableViewDelegate.

    0 讨论(0)
提交回复
热议问题