Post

Replies

Boosts

Views

Activity

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
Reply to Checkmarks are not removed from the table cell
P.S. But why is this happening? After all, next to it, in the cellForRowAt method, the same previous code is used: ... let food = foods[indexPath.row]         ...         // Assign checkmark         if food.isSelected {             cell.accessoryType = .checkmark         } else {             cell.accessoryType = .none         } ... And it works. Any ideas on this point, please.
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’21
Reply to Checkmarks are not removed from the table cell
You wrote: "Unless you call reloadRows(at:with:) or reloadData() (generally, reloadData() is too much just for updating a single cell), UITableView would not update the cell, meaning tableView(_:cellForRowAt:) would not be called." I understand that. My question is about something else - why is the same operation performed differently? Inside the cellForRowAt method, I can create a separate constant to hold the item from array and then check its isSelected property. let food = foods[indexPath.row] if food.isSelected {... But inside the didSelectRowAt method, this code does not work and I need to retrieve an item from the original array on the fly to check its isSelected property. if foods[indexPath].isSelected... What could be the reason here? Any ideas please
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’21
Reply to NavigationButton in SwiftUI
Thanks a lot!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to perform extract subview operation?
Thank you so much! It works! P.S. But one question remained with me. Why does Jacob's code work without this? Below is a screenshot of his code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to What is the empty field in the new Date Picker?
I used the Interface Bilder
Replies
Boosts
Views
Activity
Aug ’21
Reply to What is the empty field in the new Date Picker?
This is my Document Outline on the attached screenshot. I didn't use any code
Replies
Boosts
Views
Activity
Aug ’21
Reply to What is the empty field in the new Date Picker?
it is a regular TableViewController with static grouped cells. No code was used here, just an interface builder.
Replies
Boosts
Views
Activity
Aug ’21
Reply to What is the empty field in the new Date Picker?
yes it looks like the background of the cell. If I set constraints along with the margins, then the Date Picker will look like this
Replies
Boosts
Views
Activity
Aug ’21
Reply to What is the empty field in the new Date Picker?
You know, while we were discussing, I'm already used to this appearance)) I won't dive into the settings, I'll leave it as it is. Thanks a lot for your help! I and other people appreciate it very much!
Replies
Boosts
Views
Activity
Aug ’21
Reply to Why isn't the date assigned to the object property?
Thank you so much!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to No output on Xcode playground
Maybe you need to switch the mode of displaying messages in the console. It is located at the bottom of the Playground. Look at the screenshot below
Replies
Boosts
Views
Activity
Sep ’21
Reply to How to get the Force of a tap on the Screen
I think that this should be looked for in some new frameworks
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to App Development for beginners
Create your own small applications. For example, currency converter, to-do list, etc.
Topic: Business & Education SubTopic: General Tags:
Replies
Boosts
Views
Activity
Sep ’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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Checkmarks are not removed from the table cell
P.S. But why is this happening? After all, next to it, in the cellForRowAt method, the same previous code is used: ... let food = foods[indexPath.row]         ...         // Assign checkmark         if food.isSelected {             cell.accessoryType = .checkmark         } else {             cell.accessoryType = .none         } ... And it works. Any ideas on this point, please.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Checkmarks are not removed from the table cell
You wrote: "Unless you call reloadRows(at:with:) or reloadData() (generally, reloadData() is too much just for updating a single cell), UITableView would not update the cell, meaning tableView(_:cellForRowAt:) would not be called." I understand that. My question is about something else - why is the same operation performed differently? Inside the cellForRowAt method, I can create a separate constant to hold the item from array and then check its isSelected property. let food = foods[indexPath.row] if food.isSelected {... But inside the didSelectRowAt method, this code does not work and I need to retrieve an item from the original array on the fly to check its isSelected property. if foods[indexPath].isSelected... What could be the reason here? Any ideas please
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21