0

I am trying to use this controller to see what it looks like and decide whether or not to use it as a base in my own custom UIImagePickerController: https://developer.apple.com/library/content/samplecode/PhotoPicker/Listings/PhotoPicker_APLViewController_swift.html#//apple_ref/doc/uid/DTS40010196-PhotoPicker_APLViewController_swift-DontLinkElementID_5

Right now I am calling the Delegate class without any problems. However, I can't seem to use the Controller like that suggested in this video: https://www.youtube.com/watch?v=B9YWkvjB_Qc (around 4:10). I tried writing window? = APLViewController(). But I get a black screen. If I set a size and color for the window in the delegate class it will get that.

Furthermore, the controller class in the video example or the controller I am trying to use does not have any init functions. So why would I assume something would be happening when creating an instance of it and setting it as my rootViewController? This controller has also no apparent void function to call but wants UIBarButtonItems as parameters.

How can I run this "APLViewController"?

kbunarjo
  • 1,277
  • 2
  • 11
  • 27
lelelo
  • 173
  • 2
  • 12

1 Answers1

0

When working with ViewControllers it appears that there is no single init method. I worked my way through this "APLViewController", with simple print to console messages to understand better in which order it all ran.

As the instance variables where never initialized anywhere I tried doing it in the viewDidLoad function, leading me to ...is not in window hierarchy - error. In the answers here AlertController is not in the window hierarchy it was suggested doing it in viewDidAppear instead.

It did not exist so I override the viewDidAppear and initialized all the instance variables from there. Then fomr inside this function I could call all the functions within the class - and it all worked.

lelelo
  • 173
  • 2
  • 12