Type 'ViewController' does not conform to protocol 'UITableViewDataSource'

后端 未结 17 2562
旧巷少年郎
旧巷少年郎 2020-11-29 03:02

Started practice swift. In singleViewController I am trying to make a UITableView. In storyboard I set the datasource and delegate. Here I am getting the error

17条回答
  •  迷失自我
    2020-11-29 03:32

    I had just faced the same problem in Swift.

    You should realize all the functions for the UITableViewDataSource in the class, which means the following functions should be realized:

    func numberOfSectionsInTableView(tableView: UITableView) -> Int{}
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{}
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {}
    

    I'm not sure whether missing the function for numberOfSectionsInTableView works for you or not. For me, I have to realize it in my class.

提交回复
热议问题