【发布时间】:2019-07-06 08:49:31
【问题描述】:
编辑-
我有 8 个不同的 ViewController 并希望每个单元格都推送它,因此应该转到 ViewControllers 1 等。
这段代码很适合我用segue委托给另一个视图控制器,希望这段代码对你有帮助
编辑-
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if isPurchased() {
return freeQuotes.count
}
return freeQuotes.count + 1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
if indexPath.row < freeQuotes.count {
cell.textLabel?.text = freeQuotes[indexPath.row]
cell.textLabel?.font = UIFont(name: (cell.textLabel?.font.fontName)!, size:20)
cell.textLabel?.textColor = cell.textLabel?.textColor = colorLiteral
cell.accessoryType = .disclosureIndicator
} else {
cell.textLabel?.text = ""
cell.textLabel?.font = UIFont(name: (cell.textLabel?.font.fontName)!, size:20)
cell.textLabel?.textColor = colorLiteral
cell.accessoryType = .disclosureIndicator
}
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.row == freeQuotes.count {
}
performSegue(withIdentifier: segueIndenidentity[indexPath.row], sender: self)
}
【问题讨论】:
-
看看,或许对你有帮助! stackoverflow.com/questions/29913066/…
标签: swift xcode uitableview uibutton delegates