UIPageViewController NSInternalInconsistencyException

我怕爱的太早我们不能终老 提交于 2019-12-03 12:30:56

I happened to stumble upon the same error when using the following argument passed on launch:

-UIViewShowAlignmentRects YES

After wasting 2 days trying to find error within my UIPageViewController, it turned out that after disabling XCode generated yellow rectangle wrappers, the NSInternalConsistencyException evaporated.

Figured it out (at least what my problem was) - You shouldn't set a UIViewController's self.view directly, but instead use self.view.addSubview(viewA) and then use

UIView.transitionFromView(self.viewA, toView: self.viewB, duration: 0.5, options: UIViewAnimationOptions.TransitionFlipFromLeft, completion: nil)

In my case, this happened when I tried to navigate to the next page view controller inside another view controller that was presented as a modal.

Hopefully this helps other people.

I was having one 'UIPageViewController' in Storyboard and from one of the pages, I was trying to present new 'UINavigationController' with attached 'Rootviewcontroller' which was in separate xib.

When I removed xib and put this view controller as stand alone in storyboard it worked like a charm.

So I think the catch is that if both the container view are in same storyboard then it is not giving any exception or error.

let listView = String(describing: ListViewController.self)
let listViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: listView)
let navigationController = UINavigationController(rootViewController: listViewController)
self.present(navigationController, animated: true, completion: nil)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!