1

I am trying to figure out if there is a way to present a UIViewController which is not full screen. It should be of custom size & not what can be achieved using modalPresentationStyle.

I wanted to create a view like the native Twitter/Facebook sharing sheet's size with UINavigationController so that I can push/pop more UIViewControllers. It should work for iPhone and iPad.

4

2 回答 2

2

您可以使用 View Controller Containment 来执行此操作。有关更多信息,请参阅http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html上的“实现容器视图控制器” 。基本上,您只需要在将孩子的视图添加到您的视图之前调用 addChildViewController: ,然后在删除它之前调用 removeFromParentViewController: 。

于 2013-07-22T18:50:41.150 回答
0

我所做的大致是:

override func viewDidLoad() {
    super.viewDidLoad()

    self.edgesForExtendedLayout = UIRectEdge.None // Otherwise the sub view might go under the parent's navigation bar

    let vc = MyPresentedViewController()
    self.addChildViewController(vc)
    self.view.addSubView(vc.view)
}

它似乎工作正常。

于 2016-06-22T16:42:18.957 回答