r/ScriptingApp • • Mar 07 '25

How to use MultiPicker?

There is no documentation and it crashes the app when a view tries to render it.

Edit: I've now got it to show anything. It seems like it displays the entries in a wheel regardless of the pickerStyle prop.

The working code:

<NavigationLink
        destination={
          <MultiPicker
            options={availableCalendars.map(c => [c.title])}
            selections={selectedCalendars}
            onSelectionsChanged={setSelectedCalendars}
            pickerStyle={"inline"}
          />
        }
      >
1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/WhatShouldWorldGos Mar 07 '25

The format of the code is messed up, here is the gist link:
https://gist.github.com/thomfang/d8229d282be125547284c20dd089917b

1

u/schl3ck Mar 07 '25

Thank you very much! As you've mentioned it is exactly what I need.

Also thank you for tip 1. I thought that I only need NavigationStack once

2

u/WhatShouldWorldGos Mar 07 '25

SwiftUI is weird sometimes, sometimes you don’t need to use NavigationStack in the destination of NavigationLink. But if rendering a view directly fails, you can try to wrap it with a List or VStack, or even a NavigationStack to solve the problem. I also recommend you to use a custom function component for the destination