Post

Replies

Boosts

Views

Activity

ScrollViewProxy scrollTo scrolls beyond the maximum offset
Hi, I've been trying to implement a scrollIfNeeded() method for the ScrollView in SwiftUI. My aim is to make the ScrollView scroll to the selected item if it is not visible already, and don't do anything otherwise. I managed to determine if the selected item is currently visible or not, when I do this while the last item on the list is selected: proxy.scrollTo(selectedItem.id, anchor: .center) The ScrollView scrolls beyond the maximum contentOffset it can have to center the last item. What I expected it to do was scrolling to the end of the list and not going beyond that. Is this the intended behavior? It seems like a bug because the moment I tap on the scrollView, it immediately jumps to the correct offset.
0
2
557
Sep ’22
Forwarding touches from a SwiftUI View in UIHostingController to UIKit
Hi, I have a large SwiftUI view that contains a bottom menu and some small UI components above it. I want to overlay this view on top of an existing UIViewController instance and therefore using a UIHostingController. The problem I'm having is that, the transparent regions of my SwiftUI view do not forward the touches despite the background of both the SwiftUI view and the view of the UIHostingController being transparent. Since I can't replace the UIView subclass used by the UIHostingController, I can't mess with its hit testing mechanism to make it forward the touches manually. Is there a way to accomplish this? It seems to be impossible right now.
1
2
2k
Aug ’22