20.4 C
Canberra
Tuesday, March 3, 2026

debugging – SwiftUI .toolbar(placement: .keyboard) not displaying buttons on first look (iOS 18)


Background

I am constructing a SwiftUI kind (AddRecipeView) inside a NavigationStack. I’ve added a .toolbar(placement: .keyboard) with a “Achieved” button to dismiss the keyboard, particularly helpful for numberPad inputs.

Nonetheless, the “Achieved” button doesn’t seem the primary time I enter this view and faucet a TextField. After navigating away to another tab and returning and hitting thre TextField once more, the “Achieved” button reveals up accurately. This conduct occurs on each simulator and bodily gadget (each examined with iOS 18.5, and XCode’s model being 16.5).

Here is a simplified reproducible instance, but when anybody desires to examine all the mission, it may be discovered on this repo:

struct AddRecipeView: View {
    @State non-public var time: Int? = nil
    @State non-public var path = NavigationPath()

    var physique: some View {
        NavigationStack(path: $path) {
            Type {
                TextField("Time (minutes)", worth: $time, formatter: NumberFormatter())
                    .keyboardType(.numberPad)
            }
            .toolbar {
                ToolbarItemGroup(placement: .keyboard) {
                    Spacer()
                    Button("Achieved") {
                        UIApplication.shared.sendAction(
                            #selector(UIResponder.resignFirstResponder),
                            to: nil, from: nil, for: nil)
                    }
                }
            }
        }
    }
}

Console output

After I hit on the TextField for the second time (as soon as I’ve traveled to a different tab and are available again), I get these output console messages:

-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] carry out enter operation requires a legitimate sessionID. inputModality = Keyboard, inputOperation = , customInfoType = UIEmojiSearchOperations

Invalid body dimension (destructive or non-finite).

Unable to concurrently fulfill constraints.
    Most likely no less than one of many constraints within the following checklist is one you don't need. 
    ...
    "<0x6000021c7250 h="--&" v="--&" _uitoolbarcontentview.width="=">""<0x6000021aa6c0 h:="" names:="">""<0x6000021a9e00 h:="" names:="">"<0x6000021a9e00 h:="" names:=""/>0x6000021a9e00>0x6000021aa6c0>0x6000021c7250>

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles