[英]UITableView second & third label doesn't show values in the cell
在我的Tableview中,第二个和第三个标签(带有标签)没有显示任何内容,为空白。 第二个标签应显示“ Test2”,第三个标签应显示“ Test3”。
标签标签已配置(1、2和3)。 我已经尝试了一切,但仍然无法正常工作.. :(
这是我的代码:
import UIKit
import FirebaseDatabase
import FirebaseAuth
struct exerciseStruct {
let exerciseName : String!
let mainMuscle : String!
let rate : String!
}
class ExercisesViewController: UITableViewController {
var exercises = [exerciseStruct]()
override func viewDidLoad() {
super.viewDidLoad()
self.exercises.insert(exerciseStruct(exerciseName: "Test1", mainMuscle: "Test2", rate: "Test3"), atIndex: 0)
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return exercises.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell")
let label1 = cell!.viewWithTag(1) as! UILabel
label1.text = exercises[indexPath.row].exerciseName
let label2 = cell!.viewWithTag(2) as! UILabel
label2.text = exercises[indexPath.row].mainMuscle
let label3 = cell!.viewWithTag(3) as! UILabel
label3.text = exercises[indexPath.row].rate
return cell!
}
}
我的表格单元格:
我在这里做错了什么?
先感谢您!
问题出在单元格大小上。 标签在那里,但是它们不在单元格的可见区域中。 使您的单元更大,或在情节提要中添加正确的约束。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.