iOS : 'MyViewController' does not conform to protocol 'UITableViewDataSource'

后端 未结 4 2199
广开言路
广开言路 2020-12-29 05:43
  • I am new to IOS swift development. I used to work with previous Xcode 6 beta.

  • I have downloaded the Xco

4条回答
  •  清歌不尽
    2020-12-29 06:36

    class ROTableView: UITableView, UITableViewDelegate {
    
        func tableView(tableView:UITableView!, numberOfRowsInSection section:Int) -> Int {
            return 10
        }
    
        func tableView(tableView:UITableView!, cellForRowAtIndexPath indexPath:NSIndexPath!) -> UITableViewCell! {
            let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell")
    
    //        cell.text = "Row #\(indexPath.row)"
    //        cell.detailTextLabel.text = "Subtitle #\(indexPath.row)"
    
            return cell
        }
    
        func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    
        }
    }
    

    When you create the subclass for UITableView please refer the above code, you will not get any error.

提交回复
热议问题