DrasticPicker 1.0.2
dotnet add package DrasticPicker --version 1.0.2
NuGet\Install-Package DrasticPicker -Version 1.0.2
<PackageReference Include="DrasticPicker" Version="1.0.2" />
paket add DrasticPicker --version 1.0.2
#r "nuget: DrasticPicker, 1.0.2"
// Install DrasticPicker as a Cake Addin #addin nuget:?package=DrasticPicker&version=1.0.2 // Install DrasticPicker as a Cake Tool #tool nuget:?package=DrasticPicker&version=1.0.2
DrasticPicker
Access the SwiftUI Picker controller in .NET iOS, tvOS, and Catalyst apps.
How To Use
- Check the
sample
directory for a sample app.
var picker = new PickerViewWrapper(
"Sample Picker",
new[] { "Options 1", "Options 2" },
"Options 2",
CustomPickerStyle.Menu,
action =>
{
Console.WriteLine(action);
});
this.View!.AddSubview(picker.UIView);
- PickerViewWrapper is an
NSObject
that contains the SwiftUI view. Once initialized, you can access the UIView by requesting its property.
From that point on, it's a standard UIView and can be treated as such.
FAQ
Q: Why does this exist?
In the Desktop Idiom, Mac Catalyst does not support UIPickerView. Your app will throw an exception if you try to use it. Normally, in an ObjC/Swift app, you could bring in SwiftUI and use its Picker as a replacement. SwiftUI isn't bound for .NET, and there's no direct interop process for accessing Swift inside of .NET apps, so there's no direct way to call for a SwiftUI Picker. This library gives a hacky way to make that happen.
Q: Why does this not support macOS AppKit?
I believe it could, by replacing the UIHostingController wrapper with an AppKit version, but since AppKit already has the pickers I need, I didn't bother. But if you want that, you should be able to do it if you add the support within the library framework itself, fix its breaking changes, and rebind it.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-ios17.0 is compatible. net8.0-maccatalyst17.0 is compatible. net8.0-tvos17.0 is compatible. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-tvos was computed. |
-
net8.0-ios17.0
- No dependencies.
-
net8.0-maccatalyst17.0
- No dependencies.
-
net8.0-tvos17.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.2 | 217 | 12/25/2023 |