【发布时间】:2018-01-17 21:26:15
【问题描述】:
有人可以帮忙解决动态原型单元格的问题吗?
我有一个带有原型单元的“菜单”TableViewController。
有一组单元格:
let converterItems = ["Time", "Pressure", "Lenght", "Power"]
let converterImages = ["imageTime", "imagePressure", "imageLenght", "imagePower"]
和 TableView 功能:
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return converterItems.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "mainCell", for: indexPath) as! MainTableViewCell
cell.labelMain.text = converterItems[indexPath.row]
cell.imageMain.image = converterImages[indexPath.row]
return cell
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
return 60;
}
我假设我必须使用didselectatrow,但是有很多错误。
每个单元格都必须转到它的View。
【问题讨论】:
-
您是否为每个项目创建了一个转场?你的故事板中有 4 个转场吗?最好是出现在
converterItems中的名称 -
什么样的错误?
-
@MilanNosáľ 有帮助,谢谢!
-
点赞就够了
-
@MilanNosáľ 无法投票)
标签: ios swift uitableview segue