繁体   English   中英

旋转时来自UIPageViewController的NSInternalInconsistencyException

[英]NSInternalInconsistencyException from UIPageViewController when rotating

我在使用Monotouch 5.2.6和iOS SDK 5.0.1。

我有一个UIPageViewController,它是另一个视图控制器的子容器。 它是这样创建的:

pageViewController = new UIPageViewController (UIPageViewControllerTransitionStyle.PageCurl, UIPageViewControllerNavigationOrientation.Horizontal, UIPageViewControllerSpineLocation.Min);
    this.AddChildViewController (pageViewController);
    pageViewController.DidMoveToParentViewController (this);
    this.viewCurrentMode.AddSubview (pageViewController.View);

如果我旋转设备(模拟器),我在UIApplication.SendEvent()得到此异常:

抛出Objective-C异常。 名称:NSInternalInconsistencyException原因:提供的视图控制器(1)的数量与请求的脊椎位置所需的数量(2)不匹配(UIPageViewControllerSpineLocationMid)

脊柱位置不是“中间”而是“最小”。 有任何想法吗?

是的,您已将UIPageViewController初始化为“Min”作为脊椎位置。 但是,您需要为页面控制器实现委托并覆盖GetSpineLocation方法:

public override UIPageViewControllerSpineLocation GetSpineLocation (UIPageViewController pageViewController, UIInterfaceOrientation orientation)
{

    //return spine location according to interface orientation and whatever
    //criteria you prefer

}

或者,为其GetSpineLocation属性指定一个方法(MonoTouch天堂!):

pageViewController.GetSpineLocation = (p, o) => return <spinelocation>;

不过,它看起来有点意想不到的行为。 我假设本机pageViewController:spineLocationForInterfaceOrientation:的默认实现pageViewController:spineLocationForInterfaceOrientation:方法在设备旋转到横向时返回“Mid”(尽管在Apple文档中找不到信息)。 无论如何,您必须覆盖上述方法才能使其正确。

为了安全起见,我检查了UIPageViewControllerSpineLocation的值,它们与Apple的文档值相匹配。

也迪米瑞斯是正确的,默认的内部 ,委托(当未提供一个)返回UIPageViewControllerSpineLocation.Mid当未指定用户提供的回调(即,当UIPageViewController.GetSpineLocation未分配)。

这是自动生成的绑定代码所以如果没有提供默认的常量,没有提供任何内容,这有点棘手。 但是随时可以打开错误报告(并链接到这个问题),我们将看看它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM