此代码无法运行。告诉我为什么?

时间:2018-12-18 08:35:59

标签: ios

import UIKit
import AVKit

class sipinViewController: UIViewController, UITableViewDataSource,UITableViewDragDelegate{

    func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
        return cell
    }

    let  addipArray = [" 1 ","2"  ,"3  "]

    //章节里有几个cell。箭头号表示回传,一定要用return回传一个值。
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return addipArray.count
    }

    //cell里显示的内容。
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let  cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        cell.textLabel?.text = addipArray[indexPath.row]
        return cell
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
}

无法运行。不知道为什么谢谢你的时间。

1 个答案:

答案 0 :(得分:0)

您必须使用UITableViewDelegate继承协议UITableViewDataSource。 没有UITableViewDelegate,它的委托方法将不会调用。

请检查下面的代码。

class sipinViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { }

相关问题