Post

Replies

Boosts

Views

Activity

Reply to How to Choose the WatchLandmarks target in SwiftUI Tutorial?
I found the cause and fixed it. It turns out that this is a fairly well-known problem that was repeated in previous versions of the Xcode. In my case, I needed to edit the scheme and reload the Xcode. But it only worked when I shifted on another preview, and then returned to the landmarkList preview. The issue has been resolved. The topic is closed.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Checkmarks are not removed from the table cell
"How do you deselect?" I use this if condition inside of didSelectRowAt method // Set a checkmark if item.isSelected == false { cell.accessoryType = .checkmark item.isSelected.toggle()// // Remove a checkmark } else { cell.accessoryType = .none item.isSelected.toggle()// } The fact is that in this condition only the first part is executed, and the second part (else) is never executed. And I cannot understand why? "call func reloadROws..." I call tableView.reloadData() but it doesn't work.
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’21
Reply to Checkmarks are not removed from the table cell
Thank you so much! I made a following code:     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {         // Create variable and check it.         guard let cell = tableView.cellForRow(at: indexPath) else { return }          //Clean cell format before select food         cell.accessoryType = .none         // Set checkmark         if foods[indexPath].isSelected == false {             cell.accessoryType = .checkmark             foods[indexPath].isSelected.toggle()         // Remove checkmark         } else {             cell.accessoryType = .none             foods[indexPath].isSelected.toggle()         } LoadSaveData.saveToFile(foods: foods)         tableView.reloadData()     } It works!
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’21