[英]PresentViewController a non full screen UIViewController with UINavigationController in it
我試圖弄清楚是否有一種方法可以呈現不是全屏的UIViewController。 它應該是自定義大小,而不是使用modalPresentationStyle可以實現的大小。
我想使用UINavigationController創建一個類似於本機Twitter / Facebook共享表大小的視圖,以便可以推入/彈出更多UIViewControllers。 它應該適用於iPhone和iPad。
您可以使用“視圖控制器包含”來執行此操作。 有關更多信息,請參見http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html上的 “實現容器視圖控制器”。 基本上,您只需要在將子視圖添加到視圖中之前調用addChildViewController:,並在刪除它之前調用removeFromParentViewController:即可。
我所做的大致是:
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)
}
而且似乎工作正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.