Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

presentingViewController is nil when using presentViewController:animated:completion: in iOS 8

Wondering if anyone else has encountered this issue recently...

For one of my view controllers , only on iOS 8, after calling presentViewController:animated:completion:, the presented view controller has self.presentingController as nil. It is fine on iOS7, and also does not happen on another view controller.

The documentation says that it should be set, as long as the presented view controller was presented modally. Given it works in iOS 7, could this be an iOS 8 bug?

I've been able to get around it using a view container containment approach, but it would be good if someone has seen this before and knows the root cause that triggered this behaviour.

thanks

like image 431
Ken Ko Avatar asked Sep 28 '14 04:09

Ken Ko


1 Answers

Had a similar issue with iOS 8, where presentingController is nil when checking the value in viewDidLoad.

When viewDidLoad is called, there is no guarantee that the view controller hierarchy is loaded in the navigation tree. Moving the logic to a later stage (for example: viewWillAppear) should resolve that issue as presentingController should be loaded by then.

like image 132
Feras Arabiat Avatar answered Sep 25 '22 02:09

Feras Arabiat