【发布时间】:2018-07-01 01:25:29
【问题描述】:
我在 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()
}
【问题讨论】:
-
更改这一行:
cell.textLabel?.text = String(indexPath.row * Int(slider.value)) -
感谢您的帮助,第一个错误现已修复。第二个错误仍然存在:对成员 'tableView(_:numberOfRowsInSection:)' 的模糊引用我该如何解决?
-
那绝对不是 Swift 2 ????
-
不,它的swift 4。我想说有2个错误,而不是它是swift 2 ????
-
我知道,这个话题模棱两可。
标签: swift swift2 uislider xcode9.2