视图无法与故事板正确显示

时间:2014-07-10 04:41:38

标签: ios objective-c swift xcode6 xcode-storyboard

我创建了一个基于页面的应用程序,它已有多个视图。 RootViewController负责设置应用程序布局,除了一件事,视图大小外,它做的一切都很好。

这是我所拥有的一部分

    // Configure the page view controller and add it as a child view controller
    self.pageViewController = UIPageViewController(
        transitionStyle: .Scroll,
        navigationOrientation: .Horizontal,
        options: nil
    );

    self.pageViewController.delegate = self;

    // Setup the initial page
    let startingViewController = self.modelController.viewControllerWithProfileProvider(
        self.profileProviderPreference(),
        storyboard: self.storyboard
    );

    self.pageViewController.setViewControllers(
        [startingViewController as BrowsingViewControllerBase] as [AnyObject],
        direction: UIPageViewControllerNavigationDirection.Forward,
        animated: false,
        completion: { done in }
    );

    self.pageViewController.dataSource = self.modelController;
    self.addChildViewController(self.pageViewController);
    self.view.addSubview(pageViewController.view);

    // Set the page view controller's bounds using an inset rect so that self's view is visible around the edges of the pages
    self.pageViewController.view.frame = self.view.bounds;

    // Notify the page view controller that we just moved to it. This is a framework imposition. See the docs.
    self.pageViewController.didMoveToParentViewController(self);

    // Add the page view controller's gesture recognizers to the view controller's view so that the gestures are started more easily.
    self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;

控制器中的所有其他代码处理行为,而不是方面,所以我使用Storyboard设置其他所有代码。 viewControllerWithProfileProvider:方法返回正确的视图,该视图会在屏幕上显示,但不正确。这是我在故事板中的内容:

enter image description here

然后根据提供的提供商(即Facebook,Twitter,LinkedIn ...)更改按钮的颜色和标签。但我明白了:

enter image description here

注意按钮是如何离开屏幕的。我认为self.pageViewController.view.frame = self.view.bounds;是这个的关键,但我不确定要使用什么。如何才能正确显示我的观点?

2 个答案:

答案 0 :(得分:0)

我认为你需要使用,我遭受了同样的痛苦Autolayout从中拯救我。

答案 1 :(得分:0)

控制单击该框并向上拖动并从弹出窗口中选择顶部空间到顶部布局。 在左右两侧做同样的事情,分别选择前导空格和尾随空格。希望运行你的应用程序有助于