Iphone UITableViewController委托在swift中给出错误

Iphone UITableViewController委托在swift中给出错误,iphone,swift,Iphone,Swift,我在Swift Xcode 6.1中为UITableView编写简单代码时遇到以下错误 /Users/classic/Documents/CIPL/Demo Projects/DemoTableView/DemoTableView/ViewController.swift:11:1: Type 'ViewController' does not conform to protocol 'UITableViewDataSource' /Users/classic/Documents/CIPL/D

我在Swift Xcode 6.1中为UITableView编写简单代码时遇到以下错误

/Users/classic/Documents/CIPL/Demo Projects/DemoTableView/DemoTableView/ViewController.swift:11:1: Type 'ViewController' does not conform to protocol 'UITableViewDataSource'

/Users/classic/Documents/CIPL/Demo Projects/DemoTableView/UIKit.UITableViewDataSource:3:48: Protocol requires function 'tableView(_:cellForRowAtIndexPath:)' with type '(UITableView, cellForRowAtIndexPath: NSIndexPath) -> UITableViewCell'

有人知道为什么会发生此问题吗?

您是否在类中声明了UITableVIewDataSource协议的强制函数

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

您必须为tableview实现所有必需的协议方法

 override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return arrayData.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// Define your cell and return it
}

您是否在故事板中将TableViewController定义为UITableViewcontroller的子类?