【发布时间】:2016-01-16 00:53:34
【问题描述】:
这是我的历史视图,我在视图控制器中有一个表格视图。但由于某种原因,我无法输出任何内容,我正在尝试对其进行硬编码,但它根本不显示任何内容。我知道的一件事是我需要让 tableView 函数覆盖,如果我这样做,我会出错。
import UIKit
class History: UIViewController, UITableViewDataSource, UITableViewDelegate
{
@IBOutlet var tableView: UITableView!
override func viewDidLoad()
{
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "newBackground.jpg")!)
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("historyCell", forIndexPath: indexPath) as! historyCell
cell.durationLabel.text = "98"
return cell
}
override func viewWillAppear(animated: Bool)
{
super.viewWillAppear(animated)
}
}
这是我的单元原型类,我确保标识符也是“historyCell”
public class historyCell: UITableViewCell{
@IBOutlet var durationLabel: UILabel!
@IBOutlet var kicksLabel: UILabel!
}
【问题讨论】:
-
覆盖时遇到哪个错误?
标签: iphone swift uikit overriding tableview