|
Hello! I followed the tutorial https://www.hackingwithswift.com/books/ios-swiftui/importing-an-image-into-swiftui-using-uiimagepickercontroller to allow users to import their own photos in the app. I followed the tutorial closely but I have encountered some issues that I'm not sure how to fix.
The errors I am encountering are: Error 1: Cannot convert value of type 'Binding<UIImage?.Type>' to expected argument type 'Binding<UIImage?>' Error 2: Initializer for conditional binding must have Optional type, not 'UIImage?.Type' For reference, this is the ImagePicker.swift file:
Really appreciate the help!! |
|
What you have done is instantiated the inputImage with a UIImage?.Type whereas what you want is just to declare it with a type UIImage? because thats what the ImagePicker is expecting. In your SettingsBody view you need to change the following -
Change it to this -
Once you do that it should be ok to go. Hope this helps. Dave |
|
Hi, I followed your advice and removed the .self after the UIImage? but I'm getting another error (and not fixing the first two...) The error is: Expected member name or constructor call after type name
And the suggestions was to Could there be an issue with my implementations in the other areas? Thanks a lot! |
|
I tested your code and found the following: Fix the type of
This will solve the two errors, but a new one appears, because of missing
After that, the code has no errors anymore. |
|
Hi, Sorry for the late reply but I managed to get it working! Thanks a lot for your advice :) |
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.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.