【发布时间】:2016-06-15 16:39:26
【问题描述】:
我是 Swift 编程的新手,所以不要评价我很强。我花了很多时间试图了解问题出在哪里,但我无法理解。
我在 UIViewController 中有一个 UITableView
UIViewController:
@IBOutlet weak var myTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
myTableView.delegate = self
myTableView.dataSource = self
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 10
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! MyTableViewCell
cell.createNewCell()
return cell
}
在我的自定义 UITableViewCell 类中,我有 myLabel - 我在情节提要中附加的标签。
@IBOutlet weak var myLabel: UILabel!
func createNewCell(){
myLabel.text = "1234567"
}
但是,如果我在单元格更新时将以下行 cell.textLabel!.text = "12312" 添加到 cellForRowAtIndexPath,则当我尝试通过自定义 UITableViewCell 类更新单元格时,单元格不会更新。
【问题讨论】:
-
我编辑了你的问题,仍然不清楚你在问什么。你最后2句话不清楚
标签: ios swift uitableview uilabel