10

My SwiftUI View is pushed up by the keyboard despite using the .ignoresSafeArea(.keyboard) modifier:

import SwiftUI

struct PushUpView: View {
    @State var random = ""
    
    var body: some View {
        ZStack(alignment: .top) {
            Color.clear
            VStack {
                ForEach(0..<25) { id in
                    Text("Text: \(id)")
                }
                TextField("Hello, World!", text: $random)
                Spacer()
            }
        }
        .ignoresSafeArea(.keyboard)
    }
}

Pursuant to the following threads:

I thought that by using Spacer(), and by putting the keyboard avoid-er on a ZStack that has a Color.clear background that takes up all available space I'd be safe.

Alas, the problem persists. What am I doing wrong?

1
  • 5
    have you tried using GeometryReader? the view won't move up if you use it. Commented Jul 8, 2021 at 14:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.