Ios 无法将自动布局约束添加到UIPageViewController

Ios 无法将自动布局约束添加到UIPageViewController,ios,objective-c,autolayout,uipageviewcontroller,uicontainerview,Ios,Objective C,Autolayout,Uipageviewcontroller,Uicontainerview,我有一个带容器的UIView,在这个容器中,我有一个UIPageViewController,可以浏览其中的视图,类似于iPhone上的苹果股票应用程序 我正试图用它来实现所有的自动布局,但是UIPageViewController不允许我添加自动布局约束 下面代码的最后一行为“UIPageViewController”获取一个不可见的@接口,并声明选择器“addConstraints” NSDictionary *viewsDictionary = NSDictionaryOfVariable

我有一个带容器的UIView,在这个容器中,我有一个UIPageViewController,可以浏览其中的视图,类似于iPhone上的苹果股票应用程序

我正试图用它来实现所有的自动布局,但是UIPageViewController不允许我添加自动布局约束

下面代码的最后一行为“UIPageViewController”获取一个不可见的@接口,并声明选择器“addConstraints”

NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(self.con_pageViewController);
NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"[conPageViewController]"
                                                               options:NSLayoutFormatAlignAllBaseline
                                                               metrics:nil
                                                                 views:viewsDictionary];
[self.pageViewControllerPortrait addConstraints:constraints];
但是,如果我没有设置某些内容,UIPageViewController将接管整个页面,如下图所示。整个视图有一个浅绿色的背景,容器有一个粉红色的背景,UIPageViewController有一个橙色的背景,在代码中设置,我想我要在UIPageViewController中显示的视图是棕色的

如您所见,UIPageViewController采用整个视图,其中的视图将显示以下内容

如果我将UIPageViewController的框架设置为其容器的大小,则如下所示。我觉得如果我不能向UIPageViewController添加约束,那么从长远来看,这种方式将是最好的

self.pageViewControllerPortrait.view.frame = self.con_pageViewController.frame;
如果我硬编码UIPageViewController的框架,我可以得到我想要的大小,但是我不明白的是容器是220px,但是我需要将UIPageViewController设置为284px的高度,以填充容器

self.pageViewControllerPortrait.view.frame = CGRectMake(0, 0, 320, 284);
如果有人能解释这里发生了什么,我们将不胜感激

这在Interface Builder中看起来如何,以防有所帮助


好吧,我是个白痴,把UIPageViewController添加到我的视图中,而不是我的容器视图中