0

Solved: After cleaning the Build Folder and updating to newest xCode version the problem was gone for me.

I have a Navigation View and I am in a Form. My Problem is that in this Form I have a Section with a picker, which brings me by ios default with a navigationLink to a new view, which shows me all my options. This options are in a List, but as soon as this view appears they are a bit below the navgationTitle and after a second they jump up into their correct place. How can I fix this jumping problem? I thnik the problem has something to do with the Picker, because it calls the navigation link internally.

I use XCode 11.5 and here is a sample code that causes the issue:

@State var i = 0
var body: some View {
   NavigationView {
     Form {
         Section {
            Picker(selection: $i, label: Text("Pick")) {
                ForEach(0..<5,id: \.self) {
                   Text($0.description)
                }
             }
         }
     }.navigationBarTitle("PickerTest")
   }
}

This answer helped me with a very similar issue, but didn't work for this particular case https://stackoverflow.com/a/59591337/13679052

Alex B
  • 131
  • 7

1 Answers1

0

You can try adding this in the init of your View:

UITableView.appearance().tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: Double.leastNonzeroMagnitude))

This removes the default space between the NavigationBar and the Form (and prevents the jumping as well). If you want to preserve this space you can specify the height to be some other value.

Note: this will change the UITableView behaviour globally and not for this particular View only.

pawello2222
  • 46,897
  • 22
  • 145
  • 209