Swift TableView in a UIView not displaying data

后端 未结 4 1175
孤独总比滥情好
孤独总比滥情好 2021-01-05 08:32

I want to create a page which should have a map on the top and 5 row tableview at the bottom. So i created UIViewController put my Map View then put TableView. I created myV

相关标签:
4条回答
  • 2021-01-05 09:14

    try this:

    override func viewDidLoad() {
        super.viewDidLoad()
    
        // Add this
        tableView.delegate = self
        tableView.dataSource = self
    }
    
    0 讨论(0)
  • 2021-01-05 09:22

    You should do one out of two way :

    tableView.delegate = self
    tableView.dataSource = self
    

    in the viewDidLoad() of your viewController OR - select the tableView and dragging by pressing control to viewController, first select the datasource and again doing so select the delegate.

    0 讨论(0)
  • 2021-01-05 09:28

    Set the dataSource of the tableview.

    tableview.dataSource = self tableview.delegate = self

    0 讨论(0)
  • 2021-01-05 09:32

    Assign delegate and datasource of UITableView/ UICollectionView through storyboard to reduce code as follows:

    Right click on your UITableView, then click on round circle for Delegate/ Datasource and move on to the viewcontroller. For clarity, see the image below.

    Click here to view screenshot

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