stefanceriu / SCPageViewController

Just like UIPageViewController but better.. :)
MIT License
352 stars 70 forks source link

Presenting a view controller from an element #16

Closed edwinveger closed 9 years ago

edwinveger commented 9 years ago

I am trying to present a modal view controller from an element - the user is filling in a form. This present me with the warning " Presenting view controllers on detached view controllers is discouraged <ASSurveyTOCTableViewController: 0x131000e50>" where ASSurveyTOCTableViewController is an element of the PageViewController. When I check the parentViewController of ASSurveyTOCTableViewController, it is nil.

What other way would be the easiest to get the SCPageViewController from an element? As a workaround I could present the view controller from there (although undesirable).

stefanceriu commented 9 years ago

Can please check whether the pageViewController itself is added as a child view controller in your hierarchy ?

[self addChildViewController:self.pageViewController]; <-- this
[self.pageViewController.view setFrame:self.view.bounds];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self]; <-- and this

The only way I can reproduce your problem is to comment out those 2 lines above.

edwinveger commented 9 years ago

Hm, I'm definitely calling those. Copied those exact lines from your documentation in my -viewDidLoad method where I add the SCPageViewController. I must be missing something else.

Running on an iPad Air 9.1 public beta, Xcode 7.0.

stefanceriu commented 9 years ago

Okay, well I'm not really sure how I can help. If you need a reference to the page view controller you will need to pass it as a dependency yourself, although it would be a bit weird.

edwinveger commented 9 years ago

My bad. I was presenting from a UITableViewController whose UIView I added to a UIViewController element of the page controller. When adding the UIView, I forgot to set the parentViewController of the table. So I was halfway there!

stefanceriu commented 9 years ago

Cool, thanks for coming back and closing the issue.