swift - Method不会覆盖其超类中的任何方法&'UITableView'没有名为'viewDidLoad'的成员

use*_*331 0 uitableview ios swift

我很新,当我说新的时候,我的意思是我刚刚开始今天早上,我有一个问题,我试图谷歌搜索,但似乎无法找到解决方案.

我有这个swift文件:

import UIKit

class ProntoController: UITableView {

    var tableView:UITableView?
    var items = NSMutableArray()

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    func viewWillAppear(animated: Bool) {

        NSLog("Here")

        let url = "API.php"

        NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: url)!) { data, response, error in
            NSLog("Success")
        }.resume()
    }

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

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.items.count;
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier("CELL") as? UITableViewCell

        return cell!
    }


}
Run Code Online (Sandbox Code Playgroud)

我的问题是这部分代码:

override func viewDidLoad() {
        super.viewDidLoad()
    }
Run Code Online (Sandbox Code Playgroud)

我收到这两个错误:

'UITableView' does not have a member named 'viewDidLoad'
Method does not override any method from its superclass
Run Code Online (Sandbox Code Playgroud)

lib*_*bec 6

你需要子类UITableViewController,你是子类UITableView