ios – How do you get the keyboard to not push up controls at very backside of view, however nonetheless push up view to regulate for energetic TextField?

0
17
ios – How do you get the keyboard to not push up controls at very backside of view, however nonetheless push up view to regulate for energetic TextField?


In SwiftUI on iOS, I’ve the next .sheet which shows a DisclosureGroup which accommodates a DisclosureGroup inside it that has a TextField. On the very backside of the .sheet are two buttons “Cancel” and “Enter” to permit the consumer to submit information / dismiss it:

import SwiftUI

struct TestView: View
{
    @State non-public var sheetIsPresented: Bool = false
    @State non-public var outerDisclosureIsExpanded: Bool = false
    @State non-public var innerDisclosureIsExpanded: Bool = false
    @State non-public var textFieldUserInput: String = ""
    
    var physique: some View
    {
            Button("OK")
            {
                self.sheetIsPresented = true
            }
            .sheet(isPresented: self.$sheetIsPresented)
            {
                VStack
                {
                    Type
                    {
                        Part(header: Textual content("Part"))
                        {
                            DisclosureGroup("Outer Disclosure Group", isExpanded: self.$outerDisclosureIsExpanded)
                            {
                                ForEach(1...20, id: .self)
                                {
                                    index in Textual content("Worth (index)")
                                }
                                DisclosureGroup("Inside Disclosure Group", isExpanded: self.$innerDisclosureIsExpanded)
                                {
                                    TextField("Enter title", textual content: self.$textFieldUserInput)
                                    
                                }
                            }
                        }
                    }
                }
                
                HStack
                {
                    Button("Cancel")
                    {
                    }
                    .buttonStyle(.bordered).padding()
                    
                    Spacer()
                    
                    Button("Enter")
                    {
                    }
                    .buttonStyle(.borderedProminent)
                    .padding()
                }
            }
        }
}

Once I activate the TextField contained within the internal DisclosureGroup, the keyboard pushes up the “Cancel” and “Enter” buttons on the very backside of the view, in addition to adjusting the view in order that the TextField is seen because the consumer varieties:

enter image description here

I want to make it so the “Cancel” and “Enter” buttons should not pushed up, that the keyboard goes over them so they aren’t seen, but nonetheless pushes the View up in order that the TextField is seen to the consumer as they kind. .ignoresSafeArea(.keyboard, edges: .backside) doesn’t work with this code for some purpose, however even after I’ve tried it elsewhere of my code, it would push the keyboard on high of the TextField in addition to the “Cancel” and “Enter” buttons. Is there one other method to accomplish what I’ve requested about?

LEAVE A REPLY

Please enter your comment!
Please enter your name here