I am developing a new UI for my app and I am going from UIKit to SwiftUI. I want to be able to use a scrollViewProxy to manage my automatic scrolling when for example my view expands beyond the borders of the screen, and from what I've read I should use a scrollviewproxy? (any other ideas? Don't want to wrap this in UIKit!!) I must support iOS 13 in my app, BUT I have chosen to ignore this small UX design feature for those using iOS 13 so it is ok that automatic scrolling isn't supported for iOS 13 users.
This is what crashes my app with error code dyld`__abort_with_payload and also this symbol stub for: type metadata accessor for SwiftUI.ScrollViewProxy
@available(iOS 14.0, *)
@State var scrollProxy: ScrollViewProxy?
Any ideas on what I could do? Don't want to wrap this and use UIKit!
--UPDATE--
Instead of having a scrollViewProxy as a property, you can save the scroll function and use that where ever you need to programatically scroll.
Like this
@State var scroll: ((_ id: String, _ anchor: UnitPoint?) -> Void)? = nil
And then
ScrollViewReader { proxy in
mainBody.onAppear {
scroll = proxy.scrollTo
}
}
And use like this
if #available(iOS 14.0, *), let scroll = scroll {
withAnimation {
scroll("callLinkButton", .bottom)
proxy.scrollTo(, anchor: )
}
}