GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

.searchable keyboard issue

Forums > SwiftUI

Hello, I'm struggling with a problem I have when using .searchable in a List. I don't know how to avoid it, but when keyboards appears, my view moves up and the search bar and part of the list go up outside the view. It should be possible to fix content and let the keyboard overlays, right?

NavigationView {
                List(searchResult, id: \.id) { item in
                    NavigationLink(destination: CustomerDetailsView(customer: item)) {
                        ZStack(alignment: .leading) {
                            HStack {
                                ZStack {
                                    VStack(alignment: .leading) {
                                        Text("customer-name")
                                        Spacer()
                                        Text("customer-vat")
                                    }
                                }
                                .frame(width: 70, alignment: .leading)
                                Divider()
                                HStack {
                                    VStack(alignment: .leading) {
                                        HStack {
                                            Text("\(item.name)")
                                        }
                                        Spacer()
                                        HStack(alignment: .center) {
                                            HStack {
                                                Text(item.vatNumber)
                                                    .font(.system(size: CustomerView.size, weight: .heavy))
                                                    .foregroundColor(.themeSecondary)
                                            }
                                        }
                                    }
                                    .textSelection(.enabled)
                                    .padding(.horizontal, 5)
                                }
                            }
                            .padding(10)
                        }
                        .clipShape(RoundedRectangle(cornerRadius: 15))
                    }
                    .listRowBackground(Color.themeRowBackground)
                }
                .onAppear(perform: loadData)
                .navigationBarTitle("customer-navTitle")
                .toolbar{
                    NavigationLink(destination: CreateCustomerView()) {
                        Image(systemName: "person.badge.plus")
                    }
                }
        }
        .ignoresSafeArea(.keyboard)
        .searchable(text: $nameSearch)
        .navigationViewStyle(.stack)

It's not so different respecting some tutorials I saw, but I don't know how to solve it. The .ignoreSafeArea doesn't work at all. Thank you very much.

3      

Think you have attached to NavigationView and not the List. Sorry on my iPad so can not check it is.

3      

ok I will try it and give you a feedback, thank you very much!

3      

Same problem, it still doesn't work

3      

Hacking with Swift is sponsored by RevenueCat.

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

Click to save your free spot now

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.