Post

Replies

Boosts

Views

Activity

SwiftUI: Using View.scrollPostion(id:anchor) makes the ScrollView completely unscrollable
I'm trying to use the new (announced at WWDC 2023 and available in iOS 17 and macOS 14) API to observe scroll position of SwiftUI ScrollView. I have the following view, but I can't make it work correctly. That is, using the scrollPosition(id:anchor) view modifier makes the scroll view go nuts. At some point, and in some cases even at the very beginning, the scroll view just starts jumping and is stuttering when trying to scroll. See the screen recording here: https://mastodon.social/@tomkraina/111249340792812592 The code: struct ContentView: View { private var itemSize: CGSize = .init(width: 50.0, height: 50.0) // Annotated as @State to create the sections only once @State private var sectionData = makeSections() // Tracking scroll position @State private var currentItemID: MyIdentifier? var currentItemDescription: String { self.currentItemID?.stringId ?? "nil" } var body: some View { VStack { // 1. Scroll View ScrollView(.vertical) { LazyVGrid( columns: [.init(.adaptive(minimum: self.itemSize.width), spacing: Constants.columnSpacing, alignment: .center)], alignment: .center, spacing: Constants.sectionSpacing ) { ForEach(self.sectionData) { section in Section(section.title) { ForEach(section.items) { item in Text(item.text) .frame(width: self.itemSize.width, height: self.itemSize.height) } } } } .scrollTargetLayout() } .scrollPosition(id: self.$currentItemID) // TODO: Comment out this line to make the scrolling work Divider() // 2. Settings Group { Label( title: { Text(self.currentItemDescription) }, icon: { Image(systemName: "42.circle") } ) } .padding() } #if os(macOS) .frame(width: 320, height: 480, alignment: .center) #endif } } The whole code can be found in my GitHub repo: https://github.com/tomaskraina/feedbackassistant.apple.com/blob/master/ScrollPositionVsLazyVGrid/ScrollPositionVsLazyVGrid/ContentView.swift Am I doing something wrong or is this a bug in SwiftUI?
0
1
1k
Oct ’23
UIFindInteraction UI is not usable when Stage Manager is enabled
I have a problem with presenting the new find panel in an iPad app when Stage Manager is enabled. This happens both on device as well as in Simulator. The problem is that UIFindInteraction’s find panel only flicks (appears and disappears in a fraction of second) and thus is not usable for actually searching anything. Presumably, this is a UIKit bug. Has anyone found a way around it? I'm attaching a link to a demo project that does nothing special: setting isFindInteractionEnabled = true on a UITextView preseting the find panel via textView.findInteraction?.presentFindNavigator(showingReplace: false) https://github.com/tomaskraina/feedbackassistant.apple.com/tree/master/UIFindInteraction-StageManager-UIKit
5
0
1.6k
Sep ’22
SwiftUI: Using View.scrollPostion(id:anchor) makes the ScrollView completely unscrollable
I'm trying to use the new (announced at WWDC 2023 and available in iOS 17 and macOS 14) API to observe scroll position of SwiftUI ScrollView. I have the following view, but I can't make it work correctly. That is, using the scrollPosition(id:anchor) view modifier makes the scroll view go nuts. At some point, and in some cases even at the very beginning, the scroll view just starts jumping and is stuttering when trying to scroll. See the screen recording here: https://mastodon.social/@tomkraina/111249340792812592 The code: struct ContentView: View { private var itemSize: CGSize = .init(width: 50.0, height: 50.0) // Annotated as @State to create the sections only once @State private var sectionData = makeSections() // Tracking scroll position @State private var currentItemID: MyIdentifier? var currentItemDescription: String { self.currentItemID?.stringId ?? "nil" } var body: some View { VStack { // 1. Scroll View ScrollView(.vertical) { LazyVGrid( columns: [.init(.adaptive(minimum: self.itemSize.width), spacing: Constants.columnSpacing, alignment: .center)], alignment: .center, spacing: Constants.sectionSpacing ) { ForEach(self.sectionData) { section in Section(section.title) { ForEach(section.items) { item in Text(item.text) .frame(width: self.itemSize.width, height: self.itemSize.height) } } } } .scrollTargetLayout() } .scrollPosition(id: self.$currentItemID) // TODO: Comment out this line to make the scrolling work Divider() // 2. Settings Group { Label( title: { Text(self.currentItemDescription) }, icon: { Image(systemName: "42.circle") } ) } .padding() } #if os(macOS) .frame(width: 320, height: 480, alignment: .center) #endif } } The whole code can be found in my GitHub repo: https://github.com/tomaskraina/feedbackassistant.apple.com/blob/master/ScrollPositionVsLazyVGrid/ScrollPositionVsLazyVGrid/ContentView.swift Am I doing something wrong or is this a bug in SwiftUI?
Replies
0
Boosts
1
Views
1k
Activity
Oct ’23
UIFindInteraction UI is not usable when Stage Manager is enabled
I have a problem with presenting the new find panel in an iPad app when Stage Manager is enabled. This happens both on device as well as in Simulator. The problem is that UIFindInteraction’s find panel only flicks (appears and disappears in a fraction of second) and thus is not usable for actually searching anything. Presumably, this is a UIKit bug. Has anyone found a way around it? I'm attaching a link to a demo project that does nothing special: setting isFindInteractionEnabled = true on a UITextView preseting the find panel via textView.findInteraction?.presentFindNavigator(showingReplace: false) https://github.com/tomaskraina/feedbackassistant.apple.com/tree/master/UIFindInteraction-StageManager-UIKit
Replies
5
Boosts
0
Views
1.6k
Activity
Sep ’22