我在 Xcode 版本 9.2 (9C40b) 中使用 swift 得到了这些错误
- 二元运算符“*”不能应用于“IndexPath”和“Float”类型的操作数
- 对成员 'tableView(_:numberOfRowsInSection:)' 的模糊引用
@IBOutlet weak var slider: UISlider!
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 50
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
cell.textLabel?.text = String(indexPath * slider.value)
return cell
}
@IBAction func sliderValueChange(_ sender: Any) {
tableView.reloadData()
}