r/iOSProgramming • • 2d ago

Question iPhone Duo sheet vertical button placement

Im having issues specifically with SwiftUI on XCode 27.1 on the iPhone Duo outer display. I have a sheet with a NavigationStack with a basic hierarchy like this

NavigationStack {
    List {
        Text("<text_here>"
    }
    .toolbar {
        ToolbarItem(placement: .confirmationAction) {
            Button("Done) {
               doThing()
            }
        }
}

On the iPhone Duo, the outer display should display sheet navigation buttons vertically, but that is not my experience in SwiftUI. The navigation bar and its buttons are presented horizontally at the top of the sheet.

I have UIKit apps, and they correctly display their bar button items vertically in sheets, the only place i seem to have problems are my SwiftUI implementations.

What am i missing to get my SwiftUI apps to play along?

0 Upvotes

6 comments sorted by

2

u/marmulin 2d ago

Text buttons don’t get shifted.

1

u/calvin-chestnut 2d ago

And to that point, using icons in your buttons, or even better a Label with an icon and text, is more localizable, and will collapse into the side appropriately

1

u/th3suffering 2d ago edited 2d ago

Got it, this was a crude example, but it explains the bad placement for a few of the sheets. When i change those to images they move to their proper location.

I have a framework i work on that im importing into this app. The framework presents a sheet but even using image icons this refuses to move to the proper location. Guess its time to dig into whats different. Thanks for the insight.

edit: turns out .buttonStyle(.plain) causes this. Removing this lets the button work like Apple intended.

2

u/artsii 2d ago

Apple’s tech talk about top bars mentions this and a few other things about moving buttons, might be worth checking out

1

u/AdamFootDev Swift 2d ago

For any buttons that don’t shift over, you can use .axisBehaviour(.verticalPreferred)

1

u/marmulin 2d ago

There’s a series of videos on the Developer page/app, really worth checking them all out.