TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Picker set to navigationLink doesn't show any labels

Forums > SwiftUI

I have a Picker that is set to navigationLink. When you click the picker you are correctly taken through to the picker page. It then renders the list of options and a tick for the selected options. But all the options are blank text. When you click on one it changes correctly and the label on the main page updates correctly. I am only seeing this issue on iPad and not iPhone.

I have a similar picker below but set the style to 'menu' and that shoes labels just fine, but its not what i want for this UI (the labels are long).

example issue

Has anyone seen this issue before and know how to fix it?

I have the following code which renders a picker, specifically in the .navigationLink style. Its rendered in a popover with a navigation stack.

Picker(
    String(
        localized: "Single Tap",
        comment: "The label that is shown next to the single tap action"
    ),
    selection: $tapAction
) {
    ForEach(Action.tapCases) { currentTapAction in
        Text(currentTapAction.display)
    }
}.pickerStyle(.navigationLink)

Here is the code for the Action enum that is being used.


enum Action: String, CaseIterable, Identifiable, Codable {
    case next, back, none, fast, select, delete, clear, startScanning
    var id: Self { self }

    static public var tapCases: [Action] = [.next, .back, .none, .select, .delete, .clear, .startScanning]
    static public var holdCases: [Action] = [.next, .back, .none, .fast, .select, .delete, .clear, .startScanning]

    var display: String {
        switch self {
        case .none: return String(
            localized: "None",
            comment: "Label for action that happens on a keypress"
        )
        case .next: return String(
            localized: "Go to the next item",
            comment: "Label for action that happens on a keypress"
        )
        case .back: return String(
            localized: "Go to the previous item",
            comment: "Label for action that happens on a keypress"
        )
        case .fast: return String(
            localized: "Quickly scan through the items",
            comment: "Label for action that happens on a keypress"
        )
        case .select: return String(
            localized: "Select the currently selected item",
            comment: "Label for action that happens on a keypress"
        )
        case .delete: return String(
            localized: "Delete the last inputted letter",
            comment: "Label for action that happens on a keypress"
        )
        case .clear: return String(
            localized: "Clear all the inputted text",
            comment: "Label for action that happens on a keypress"
        )
        case .startScanning: return String(
            localized: "Start scanning from the current item, scanning must be enabled",
            comment: "Label for action that happens on a keypress"
        )
        }
    }
}

2      

@gavin is asking for insight:

But all the options are blank text.
When you click on one it changes correctly and the label on the main page updates correctly.
I am only seeing this issue on iPad and not iPhone.

More info needed.

This occurs on actual devices? or just within the simulators?

2      

Hey @Obelix I have seen it occur on both real devices and a simulator.

For now I have built my own Picker but I would rather use the native component.

2      

If you can capture the actual objects in a debugging session and verify the contents of the labels exist but are not displayed, you've probably uncovered a bug. Nice job! You've probably already submitted a report to Apple. Please return and let us know if this gets resolved.

2      

Hacking with Swift is sponsored by RevenueCat.

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

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

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.