numberOfSectionsInTableView not working

后端 未结 3 1425
清歌不尽
清歌不尽 2021-01-06 09:53
import UIKit

class exploreViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    @IBOutlet weak var searchBar: UISearchBar!
    @IBOutle         


        
3条回答
  •  孤独总比滥情好
    2021-01-06 10:35

    From your code, I believe you are using Swift3. Then, the following are delegate and datasource methods for UITableView in Swift3

    func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
    
        // Configure the cell...
    
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    
    }
    

    As you can see, your numberOfSections function's syntax is wrong.That is the reason.

提交回复
热议问题