Я очень новичок в программировании Swift, поэтому не судите меня сильно. Я потратил много времени, пытаясь понять, где проблема, но я не могу ее получить.UILabel не обновляется с помощью пользовательского класса UITableViewCell Swift
У меня есть UITableView внутри UIViewController
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 предложения не ясны – Honey