InsertSubviewBelow无法正常工作;视图显示上面的其他视图

时间:2017-03-17 15:23:55

标签: c# ios xamarin xamarin.ios

你们有个问题。在我的计划中,我有UIPageViewController通过this.NavigationController.AddChildViewController(pvController)添加为子视图控制器,并通过View.AddSubview(pvController.View)

添加为当前视图的子视图

我添加了一个到我的视图的过渡,使其在Y轴上向下滑动250个单位:

UIView.Transition(this.View, 1.5, UIViewAnimationOptions.CurveEaseOut, () =>
            {
                this.View.Frame = animateTo;
            }, null);

我希望另一个UIView位于UIPageViewController.View后面,这样当我触发转换时,另一个视图似乎会滑入到位。问题是,我已经尝试了很多方法来做到这一点无济于事。以下是我迄今为止尝试过的所有方法:

        View.SendSubviewToBack(behind);
        pvController.View.InsertSubviewBelow(behind, pvController.View);
        pvController.View.InsertSubviewAbove(behind, pvController.View);
        pvController.View.SendSubviewToBack(behind);

它们都导致相同的事情:UIView behind显示在上面 pvController.View

有人有什么想法吗?非常感谢帮助!

2 个答案:

答案 0 :(得分:0)

不是解决问题的方法,而是可以用来帮助解决问题的方法。

在XCode中,可以debug your view hierarchy,这可以帮助您查看您的观看位置。

要访问此功能,请在应用处于断点时单击此窗口:

enter image description here

然后在XCode中显示以下内容:

enter image description here

希望这可以帮助您找出视图的位置。

答案 1 :(得分:0)

修好了!它比我想象的要简单一些;但是,我仍然想知道为什么InsertSubviewBelow不起作用。

以下是我为达到理想效果而采取的措施:

View.AddSubview(pvController.View);
View.AddSubview(behind);
View.SendSubviewToBack(behind);

加载视图后ViewDidLoad()behind确实落后于pvController.View