0

i am using a third parties View controller that needs to be initialised.

I am currently launching it programtically througbh a modal. It requires you pass it a UIImage to initiated the controller.

Currrently i am doing as follows

let thirdPartyVC = ThirdPartyViewController(image: myUIImage)



 present(photoEditViewController, animated: true, completion: nil)

What i would like to do to do this with segues instead but i cant seem to work out how to initialise the controller with the image.

Currently i am trying to make a ThirdPartyViewController in the storyboard.

i am then performing a segue to it and trying to set the image in prepare for segue as follows bellow.

  override func viewDidLoad() {
        super.viewDidLoad()

       operformSegue(withIdentifier: "segueToThirdPartyVc", sender: Any?) 


    }

   override func prepare(for segue: UIStoryboardSegue, sender: Any?) {


        switch segue.identifier! {
        case "segueToThirdPartyVc" :

             let destination = segue.destination as?  ThirdPartyViewControllerInstance

             destination.image = aUIIMage


        default:
        break

        }

Unfortunatly this is failing to initalise the controller. How do i sucessfuly init the controller.

Susan Ho
  • 83
  • 2
  • 7
  • First thing is that are you getting a compile time error or a run time error? – Harsh Mar 17 '18 at 02:42
  • Possible duplicate of [Custom init for UIViewController in Swift with interface setup in storyboard](https://stackoverflow.com/questions/35315404/custom-init-for-uiviewcontroller-in-swift-with-interface-setup-in-storyboard) – Smartcat Mar 17 '18 at 02:43
  • 2
    Also, consider having a normal view controller be what you segue to, set up in your storyboard. But then put the custom view controller inside it using a container view, programmatically added during the normal view controller's viewDidLoad() – Smartcat Mar 17 '18 at 02:45
  • how would you add it programmatically non modally in the container? Is it possible for it just to fill the container? – Susan Ho Mar 17 '18 at 22:39

0 Answers0