Post

Replies

Boosts

Views

Activity

ScrollView + .refreshable
How can I add a native UX for pull-to-refresh for a ScrollView? Is support for this being added in iOS 16? Right now, the native UX only appears for List. For example, I want to support to be able to support .refreshable on a ScrollView like this: var body: some View {     ScrollView {       LazyVStack {         Text("1")         Text("2")         Text("3")       }     }     .refreshable {       ///     }   }
4
2
5.7k
Jun ’22
SwiftUI default focus on TextField/TextEditor when view is loaded
Let's say I have a SwiftUI view that's a compose experience, like composing a new email in Mail, an iMessage in Messages, or a Tweet in Twitter. When the view is loaded, I want the soft keyboard to appear automatically so that the user can type immediately without needing to manually put focus in the TextField or TextEditor by tapping on it. With the new @FocusState feature in iOS 15, I can programmatically put focus on different TextFields when the user interacts elsewhere in the UI (like pressing a button), but I can't seem to set a default focus. I tried initializing focus in the SwiftUI view's init method as well as the onAppear method attached to other parts of the view, but this didn't seem to have any effect. How can I put default focus on a TextField or TextEditor when a view is loaded?
7
0
24k
Jun ’21