У меня есть UITableView
в ViewController
, который отображает Default
, пять раз работает в симуляторе на основе следующего кода.Как изменить текст метки в UITableView на основе нажатой кнопки?
class ViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {
@IBOutlet weak var myTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
}
func tableView(_ tableView:UITableView, numberOfRowsInSection section:Int) -> Int
{
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let myCell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! OutsideCell
myCell.titleLabel.text = "Default"
return myCell
}
@IBAction func firstButtonPressed(_ sender: Any){
}
@IBAction func secondButtonPressed(_ sender: Any) {
}
}
У меня также есть 2 кнопки в нижней части ViewController
и мне нравится показывать текст First Button
когда это firstButtonPressed
и Second Button
когда secondButtonPressed
вместо Default
в UITableView
. Как это возможно?
Цените это, что работает там так или иначе я могу сделать первую кнопку появляться, когда вид нагрузки на первый раз вместо используемого по умолчанию? – leaner122
В вашей функции cellForRow просто используйте другое текстовое значение вместо Default. – TheValyreanGroup