Populate table view in swift

后端 未结 2 2028
栀梦
栀梦 2021-02-13 13:45

Hi i want to populate this tableview \"configuration

i don\'t use the static table view because i tak

2条回答
  •  野性不改
    2021-02-13 14:40

    The cells in the storyboard are prototype cells. That means they are not actually in the table view, but can be used as templates.

    In order to populate the tableview, you need to:

    1. In the storyboard, set your view controller to be the datasource of the tableview by dragging the "datasource" connection from the connections menu of the table view to your view controller.
    2. Make your view controller conform to the UITableViewDataSource protocol.
    3. Implement the following methods in your view controller:
      • func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
      • func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

提交回复
热议问题