0
votes

i am new to SwiftUI programming, i've made a view but once the user taps on the textfield the keyboard appears and the entire view pushes up, how do i fix this?

1
nope in a sense that i made a sign up page and once i tap on a textfield it pushes the view upjaz01
i just had seen online that only way of resolving this is including a scroll view since the ignoresSafeArea doesn't work with a VStackjaz01
can you help @Andrewjaz01
@jnpdx could you help me pleasejaz01
@jaz01 as has been pointed out, this question has been answered before on SO. If the existing solution doesn't work for you, you would need to show the code you've tried and explain why your situation is different and how the existing solution failed to work.jnpdx

1 Answers

5
votes

I believe you can use .ignoresSafeArea(.keyboard)

I tested this code in XCode 12.4 and simulator iOS 14.4

struct ContentView: View {
  var body: some View {
      VStack {
        Spacer()
        Group {
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
        }
        HStack{
          Spacer()
          TextField("INPUT", text: .constant("HERE IS INPUT"))
          Spacer()
        }
        Group {
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
          Text("Content")
        }
        Spacer()
      }
      .ignoresSafeArea(.keyboard)
  }
}