1

Xcode 11.4.1

Thanks for this thread all Why is SwiftUI picker in form repositioning after navigation?. Helped me solve my horizontal shifting section heading when a if else section was made dependent on it to show.

For example:

Section(header: Text("Subject Identified").listRowInsets(EdgeInsets()).padding(.leading)) {
                Picker(selection: $subIndex, label: Text("Test")) {
                    ForEach(0 ..< subIdentified.count) {
                        Text(self.subIdentified[$0]).tag($0)
                    }
                }
            .labelsHidden()
            .pickerStyle(SegmentedPickerStyle())
            }
                Section {
                    if subIndex == 0 {
                        TextField("First Name", text: $firstName)
                        TextField("Last Name", text: $lastName)
                        TextField("DOB", text: $dateOfBirth)
                    } else { }
                }

I have one more issue I'm trying to solve and I've tried using different modifiers and not sure I'm putting it in right place. I'm kinda new to this and I'd really appreciate guidance and instruction.

My picker selection screen shifts all text horizontal. I used the vertical stack modifier to fix the vertical shift but I'm still getting the horizontal 2-4 pixel shift.

            Section(header: Text("Reason for evaluation")) {
                Picker(selection: $reasonIndex, label: Text("Test")) {
                    ForEach(0 ..< reasonFor.count) {
                        Text(self.reasonFor[$0]).tag($0)
                    }
                }
                .labelsHidden()
            }

I've tried using (padding added because I do want it off the edge, I just don't want it to jump and this fixed the above section for me);

.listRowInsets(EdgeInsets()).padding(.leading))

and...

.listRowInsets()

For example, I tried the following:

Section(header: Text("Reason for evaluation"), .listRowInsets()) {
                Picker(selection: $reasonIndex, label: Text("Test")) {
                    ForEach(0 ..< reasonFor.count) {
                        Text(self.reasonFor[$0]).tag($0)
                    }
                }
                .labelsHidden()
            }

Please help guide me in the right direction. I'm guessing I'm not putting the modifier where it applies to the view correctly.

Sean
  • 43
  • 6

0 Answers0