0

I'm trying to get taking photos working on an iOS app. To do so, I do the following...

imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
imagePicker.allowsEditing = true
self.presentViewController(imagePicker, animated: true, completion: nil)

The issue I have is that I keep getting:

2016-02-28 13:12:17.767 Instagram[60379:2605934] Presenting viewcontrollers on detached view controllers is discouraged <Instagram.ViewController: 0x7937ed50>.
2016-02-28 13:12:18.282 Instagram[60379:2605934] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7a402a00>.

Whenever I try to do this. I assumed this had something to do with not transitioning to the ViweController correctly (there are two ViewControllers before this one - ViewController (where users login), and PhotoTableController (where users view a feed, and can press to add their own photo).

The first way I tried to transition between the two was the way I've always done it programmatically:

self.performSegueWithIdentifier("loginSegue", sender: nil)

But that caused the error above. So I thought I should use the "presentViewController" like I did for the imagePicker:

self.presentViewController(PhotoTableController(), animated: true, completion: nil)

I did something similar for the transition from PhotoTableController to PostPhoto as well, but it didn't matter because when the user would login and do that first transition, the screen would go completely black.

I'm not sure what exactly is causing this issue, or if I'm going about solving the issue correctly. And a lot of what I google is Objective C code, which I cannot understand.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
CaptainForge
  • 1,365
  • 7
  • 21
  • 46
  • Have you tried: `navigationController?.pushViewController(animated:)`? – Eendje Feb 28 '16 at 18:27
  • Does this help? http://stackoverflow.com/a/21003988/1305067 – paulvs Feb 28 '16 at 18:44
  • Where are you calling this code? From `viewDidLoad`? If so, that's too early in the process. You can defer this until `viewDidAppear` (though have a state variable that keeps track of whether you've presented it already) and you eliminate these sorts of warnings. – Rob Feb 28 '16 at 19:02
  • I'm calling the code when the user presses a button – CaptainForge Feb 29 '16 at 00:31

0 Answers0