(OLD) Using coordinators to manage SwiftUI view controllers - Instafilter SwiftUI Tutorial 6/12

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ต.ค. 2024
  • In this project you'll learn how to incorporate UIKit UIViewControllers into your SwiftUI app.
    This is part of the Hacking with iOS tutorial series, which teaches SwiftUI for free. You can read it online here: www.hackingwit...

ความคิดเห็น • 21

  • @csmac3144a
    @csmac3144a 3 ปีที่แล้ว +5

    Hey Paul -- you're definitely one of the better tutors on TH-cam for Apple developers. Thanks for these videos!

  • @ToddHoff
    @ToddHoff 3 ปีที่แล้ว

    Perhaps this could be more difficult, but I'm not sure how. Thanks for the good explanation. I have my own controller, so I figured I had to make my own delegate protocol and that seemed to work.

  • @ZhouHaibo
    @ZhouHaibo 4 ปีที่แล้ว

    Awesome explanation! I think we don't need the func loadImage & double image property in contentView in this case. In my code, I add an empty check of inputImage in body view. Then if the image return from ImagePicker is not nil, it will be presented in contentView.
    ------------------------------------------------------------------------------------
    struct ContentView: View {
    @State private var showingImagePicker = false
    @State private var inputImage: UIImage?
    var body: some View {
    VStack {
    if inputImage != nil {
    Image(uiImage: inputImage!)
    .resizable()
    .scaledToFit()
    } else {
    // Some place holder here
    }
    Button("Select Image") {
    self.showingImagePicker = true
    }
    }
    .sheet(isPresented: $showingImagePicker) {
    ImagePicker(image: self.$inputImage)
    }
    }
    }

  • @volimpia
    @volimpia 4 ปีที่แล้ว

    This is hard to remember but it's 12 minutes, so i just refer to this video or to this code and create something similar when i have to. Last time i had to use custom tableview class(it was in fact a viewcontroller with two table views that communicated with each other), and after struggling how to pass selected data to swiftui view, how handle updating the view when array of items is changed(deleted, inserted, moved) and getting confused when it said Coordinator class does not conform to protocol(i mean, what must have i written in cellatrow and numberofsection functions , that i needed to add to Coordinator after conforming to datasource and tableviewdelegate? So i just created simple protocol with one func, an comformed Coordinator to that protocol, an yep! i had to implement just that one func, that passed the data that i wanted. So it is a great workaround to create your own protocol for Coordinator if you want to pass data.

  • @stephankorner9
    @stephankorner9 4 ปีที่แล้ว +2

    Excellent explanation ! One question: why are two images needed (i.e. image and inputImage) - couldn't we omit image and use inputImage instead (and therefore omit onDismiss and loadImage ? After all, the binding should go all the way, shouldn't it ?

    • @medgarfsantos
      @medgarfsantos 3 ปีที่แล้ว

      Probably a bit late but here is my take: you cannot use UIImage directly because UIImage does not conform to View, and therefore cannot be part of the "body", that's why he instantiates the swiftUI Image using the init(uiImage: ) which will (most likely) extract all the underlying UIImage data to an object conforming to View, in this case "Image".

  • @J4raz
    @J4raz 4 ปีที่แล้ว +4

    Thanks for the video. However, for the feature itself, i think it is ridiculously overcomplicated. I'm not sure if Swift(or SwiftUI) is going in the good direction anymore.

    • @fredericadda
      @fredericadda 4 ปีที่แล้ว +1

      Sorry, that's all Objective-C legacy code, predating even UIKit. On the contrary, I'm convinced that Swift and SwiftUI will make that process much simpler.

  • @egormerkushev
    @egormerkushev 4 ปีที่แล้ว

    Top of the top 🏔!

  • @muradjam
    @muradjam 4 ปีที่แล้ว

    when presenting the picker there is no way to dismiss it (by drag-down) before choosing any image

  • @chooseyourfuturebeforeitch7453
    @chooseyourfuturebeforeitch7453 3 ปีที่แล้ว

    Any update?
    if let uiImage = info[.originalImage] as? UIImage {
    parent.image = uiImage
    }
    the compiler shows no image variable.

  • @bonnydonny
    @bonnydonny 4 ปีที่แล้ว

    holy cow! I want HyperCard back.

  • @pickemparty
    @pickemparty 4 ปีที่แล้ว

    How can the user delete/remove the selected photo?!

  • @penelope5004
    @penelope5004 4 ปีที่แล้ว

    So hard! Great tutorial though. I keep getting this error when I run the code, does anyone else experience this?
    "Thread 1: Fatal error: Reading Environment outside View.body"
    It seems to be related to the line "parent.presentationMode.wrappedValue.dismiss()"

  • @FelipeGomez-wf7lb
    @FelipeGomez-wf7lb 4 ปีที่แล้ว

    Baffling,... thanks Paul.

    • @salvadornehemiah1459
      @salvadornehemiah1459 3 ปีที่แล้ว

      A trick : watch movies on kaldrostream. Been using them for watching a lot of movies during the lockdown.

    • @harleyjordan7914
      @harleyjordan7914 3 ปีที่แล้ว

      @Salvador Nehemiah Yup, been using Kaldrostream for months myself =)

  • @adlsfreund
    @adlsfreund 3 ปีที่แล้ว +2

    &£!% Apple! What an unholy tangle of code just to present a system-provided image picker! It should be one, two, or maaaaybe three lines of code max! What is even happening? How does makeUIViewController actually get called? What is a context? Why does the coordinator have to be a separate type? I know you tried your best to explain it, but it doesn't work for me. This seems like a whole lot of code that should be Apple's responsibility, not the developer's. Just let me specify a binding and a callback and be done with it... UIKit: not even once. 😵 I can only hope to be able to copy & paste this code correctly when I will need it, let alone understand it, but thank you!

    • @feitingschatten1
      @feitingschatten1 3 ปีที่แล้ว

      I see you're not susceptible to the brainwash of repeating "It's simpler" over and over while they make any developer who wants to do more than a simple image and list's life miserable.

  • @vindajojo
    @vindajojo 4 ปีที่แล้ว

    But how to use storyboard with view controller to swiftUI, the ibaction didn't work.