UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SwiftUI, iOS 14, Keyboard Avoidance in Form{ TextEditor() }

Forums > SwiftUI

@bci  

I am having a problem on a simple Form{}. Automatic Keyboard Avoidance is not working. Below is a small form with a TextEditor(). When run, the keyboard sits on top the input field, requiring the user to scroll the view so thay can enter a location. Remove the Form{} and Automatic Keyboard Avoidance works. Am I missing something I need to do in a Form{} to get this behavior?

import SwiftUI
struct ContentView: View {
    @State private var stopLocation: String = ""
    var body: some View {
        Form {
            let desc = "\n\n\n\n\n\n\n\n\n\n\n\nEnter Location"
            Text(desc)
            VStack {
                TextEditor(text: $stopLocation)
            }
        }
    }
}

Thank you.

4      

Hello! Can you please share any update on this? It's really a pain to adopt the whole keyboard avoidance mechanism for just one element like TextEditor().

Would really appreciate!

3      

Having same problem... anyone?

UPDATE I think I found a solution. https://www.vadimbulavin.com/how-to-move-swiftui-view-when-keyboard-covers-text-field/

4      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.