|
I'm struggling a lot with the Day 77 Challenge Right now, my main issue is that I don't understand how to make one sheet pop up with a PHPickerViewController, but then have another sheet pop up immediately after an image is selected, so that the user can enter a name for the selected photo. So far I have this in ContentView...
and this is the ViewModel for it
and this is the data model...
With what I have right now, I am able to run the code and tap the (+) button to get the image picker to pop up and let me select an image. But I don't know how to make that image selection trigger another sheet to pop up with another view. |
|
In a past project, we used the I'm not sure if that will cause problems when I try to pass a binding to a wrapped property to the ImagePicker though... I'm not currently working on the project now, and this kind of seems like I'm sending myself on a wild goose chase, but if somebody doesn't stop me with a better solution before I get home, I think I'll try that I guess. |
|
@ostrich is trying to apply Swift to a logic problem...
This is a great time to stare at the lights in your room. Perhaps you have two lights in your computer room? On is a ceiling lamp, the other is a desk lamp near your computer. What are the controls to turn these lights on or off? You have two light switches?! Yes? Each switch has a state: On or Off. Or you can think of them as So what you really have is not a Swift "show a pop up" problem. What you have is a logical, "How do I control the lights?" problem. If you energize one of the switches, it will turn on the overhead lamp, but not the desk lamp. When you turn the overhead lamp OFF, you want the desk lamp to automatically turn on. Then when you turn the desk lamp off, you want to ensure the overhead lamp is also off. Think of the states of your app's sheets as light switches. Under what conditions do you want the sheet with the This is a logic problem! Return here please, and share your logical solution. |
|
I was able to get it to work after changing my data model a bit and giving it a different type of initializer. Although, using this modifieer still doesn't work with a binding to UIImage? because it must conform to identifiable I guess.
Error message: Instance method 'sheet(item:onDismiss:content:)' requires that 'UIImage' conform to 'Identifiable' But I eventually got it to work using this modifier instead
I think I was just running into a problem with going this route because of the way that my EditView initializer was set up before. If you want to see how I have changed the files I mentioned above to solve the problem, they look like this now (although, the project still isn't complete yet. ContentView.swift
ContentView-ViewModel.swift
NamedFace.swift
|
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
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.