Post

Replies

Boosts

Views

Activity

How do I programmatically implement editing of a UITableViewCell?
I have a UITableView added as a subview to a UIViewController and I used the built-in editButtonItem with self.navigationItem.rightBarButtonItem = editButtonItem Also, after reading other forum threads, I called these functions: func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return true } override func setEditing(_ editing: Bool, animated: Bool) { super.setEditing(editing, animated: true) tableview.setEditing(editing, animated: true) } When I tap "Edit", it does toggle the red minuses for each cell and it changes to "Done", but I still can't edit the text for the cells. Am I missing something?
1
0
769
Apr ’22
How do I access stored properties from another UIViewController programmatically?
How can I add append addedItem in SecondViewController to items array in FirstViewController programmatically? class FirstViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var items: [String] = [] } class SecondViewController: UIViewController { let textField: UITextField = UITextField() let saveButton: UIButton = UIButton() @objc func saveButtonTapped() { let addedItem = textField.text } }
1
0
775
Mar ’22
How do I programmatically implement editing of a UITableViewCell?
I have a UITableView added as a subview to a UIViewController and I used the built-in editButtonItem with self.navigationItem.rightBarButtonItem = editButtonItem Also, after reading other forum threads, I called these functions: func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return true } override func setEditing(_ editing: Bool, animated: Bool) { super.setEditing(editing, animated: true) tableview.setEditing(editing, animated: true) } When I tap "Edit", it does toggle the red minuses for each cell and it changes to "Done", but I still can't edit the text for the cells. Am I missing something?
Replies
1
Boosts
0
Views
769
Activity
Apr ’22
How do I access stored properties from another UIViewController programmatically?
How can I add append addedItem in SecondViewController to items array in FirstViewController programmatically? class FirstViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var items: [String] = [] } class SecondViewController: UIViewController { let textField: UITextField = UITextField() let saveButton: UIButton = UIButton() @objc func saveButtonTapped() { let addedItem = textField.text } }
Replies
1
Boosts
0
Views
775
Activity
Mar ’22