Я пытаюсь сделать tableViewCell, что каждая из них имеет разную высоту. Я попытался объявить каждый из идентификаторов ячеек и его имя и разделить на случаи на используя «переключатель». И, во-вторых, я также хочу указать lable на mainViewCell, который находится в коде. Как я могу изменить каждую высоту ячеек?Как сделать пользовательский TableViewCell, который у каждого из них имеет разную высоту
import UIKit
class TableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewdidload()
tableView.registerNib(UINib(nibName: "mainViewTableViewCell", bundle: nil), forCellReuseIdentifier: "mainViewCell")
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
tableView.scrollEnabled = false
return 4
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch tableView.numberOfRowsInSection(4) {
case 0:
let titleCell = tableView.dequeueReusableCellWithIdentifier("titleCell")! as UITableViewCell
return titleCell
case 1:
let wayCell = tableView.dequeueReusableCellWithIdentifier("whichWayCell")! as UITableViewCell
return wayCell
case 2:
let campusCell = tableView.dequeueReusableCellWithIdentifier("campusCell")! as UITableViewCell
return campusCell
default :
let mainViewCell = tableView.dequeueReusableCellWithIdentifier("mainViewCell")! as! mainViewTableViewCell
mainViewCell.mainViewLabel.text = onUpdate(timer)
return mainViewCell
}
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
switch tableView.numberOfRowsInSection(4) {
case 0:
tableView.numberOfRowsInSection(1)
return 50
case 1:
tableView.numberOfRowsInSection(2)
return 50
case 2:
tableView.numberOfRowsInSection(3)
return 50
default:
tableView.numberOfRowsInSection(4)
return 300
}
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
}
В чем проблема u r? –
На самом деле, я хочу указать строку и изменить только одну высоту ячеек, но она будет зависеть от всех ячеек, чтобы подвести итог, я хочу настроить каждую ячейку разными способами, но настройка будет применяться ко всем ячейкам, и это это будет проблема – yanamstyle
как насчет этого на раскадровке? – adolfosrs