Reputation: 33048
I'm on Monotouch 5.2.6 and iOS SDK 5.0.1.
I have a UIPageViewController that is a child container of another view controller. It is created like this:
pageViewController = new UIPageViewController (UIPageViewControllerTransitionStyle.PageCurl, UIPageViewControllerNavigationOrientation.Horizontal, UIPageViewControllerSpineLocation.Min);
this.AddChildViewController (pageViewController);
pageViewController.DidMoveToParentViewController (this);
this.viewCurrentMode.AddSubview (pageViewController.View);
If I rotate the device (Simulator), I get this exception in UIApplication.SendEvent()
:
Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: The number of provided view controllers (1) doesn't match the number required (2) for the requested spine location (UIPageViewControllerSpineLocationMid)
The spine location is NOT "mid" but "min". Any ideas?
Upvotes: 5
Views: 893
Reputation: 43553
To be safe I checked the values for UIPageViewControllerSpineLocation
and they match the values of Apple's documentation.
Also Dimitris is right, the default internal, delegate (when one is not provided) returns UIPageViewControllerSpineLocation.Mid
when a user-provided callback is not specified (i.e. when UIPageViewController.GetSpineLocation
is not assigned).
That's autogenerated binding code so it's a bit tricky not to return a constant for the default, nothing provided, case. However feel free to open a bug report (and link to this question) and we'll have a look at it.
Upvotes: 0
Reputation: 8170
True, you have initialized the UIPageViewController with "Min" as spine location. However, you need to implement a delegate for your page controller and override the GetSpineLocation
method:
public override UIPageViewControllerSpineLocation GetSpineLocation (UIPageViewController pageViewController, UIInterfaceOrientation orientation)
{
//return spine location according to interface orientation and whatever
//criteria you prefer
}
Or, assign a method to its GetSpineLocation
property (MonoTouch heaven! ):
pageViewController.GetSpineLocation = (p, o) => return <spinelocation>;
Still, it looks a bit unexpected behavior. I assume that the default implementation of the native pageViewController:spineLocationForInterfaceOrientation:
method returns "Mid" when the device rotates to landscape (although could not find info in Apple docs). Anyway, you must override the above method to get it right.
Upvotes: 4