Post

Replies

Boosts

Views

Activity

Reply to Massive Memory Leak in SwiftUI for macOS
I just pasted your code into Xcode, ran it, and started clicking around. It seems a bit bogged down, because it can take over a second to change the VeryComplexView when I click on the different numbers in the left nav. But, the memory use is staying around 100-150MB. I'm running macOS 11.2.3, so maybe you could try upgrading to that?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to List with EditButton for selection, delete, and move
I think so, but I'm not sure exactly what you're trying to do. Here, I copied the code from the documentation for EditButton, and added some ability to select by tapping the text. (Probably you want to render the selection in a different way, not just green text, but I did that for simplicity.) struct ContentView: View {     @State private var fruits = [         "Apple",         "Banana",         "Papaya",         "Mango"     ]     @State private var selected = Set<String>()     var body: some View {         NavigationView{             List {                 ForEach(fruits, id: \.self) { fruit in                     Text(fruit)                         .foregroundColor( selected.contains(fruit) ? Color.green : nil )                         .onTapGesture { toggleSelected(fruit) }                 }                 .onDelete { self.deleteFruit(at :$0) }                 .onMove { self.moveFruit(from: $0, to: $1) }             }             .navigationTitle("Fruits")             .toolbar { EditButton() }         }     }     func toggleSelected(_ fruit: String) {         if selected.contains(fruit) { selected.remove(fruit) }         else { selected.insert(fruit) }     }     func deleteFruit(at: IndexSet) { fruits.remove(atOffsets: at) }     func moveFruit(from: IndexSet, to: Int) { fruits.move(fromOffsets: from, toOffset: to) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to UIScrollView does not give touches to subview if drag starts quickly
My problem was caused by something dumb that I left out of my question, because I was trying to simplify it to post here. My UIScrollView was actually inside a SwiftUI view hierarchy, using UIViewRepresentable. Higher in that view hierarchy, there was a SwiftUI List, which also has scrolling. I had forgotten about that List because I was using it for it's layout appearance, grouping items into sections, but not for its scrolling. Once I got rid of that List, everything worked as expected.
Topic: UI Frameworks SubTopic: UIKit Tags:
Feb ’22