简体   繁体   English

如何将视图控制器作为视图的一部分呈现?

[英]How to present a view controller as a part of a view?

I am trying to present a UIReferenceLibraryViewController in a view. 我试图在视图中呈现UIReferenceLibraryViewController Normally when using UIViewController.present() it would cover up the whole screen, but I want it to be just a part of the screen. 通常在使用UIViewController.present()它会覆盖整个屏幕,但我希望它只是屏幕的一部分。 How can I do that? 我怎样才能做到这一点?

What I have: 我有的:

import UIKit
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        let controller: UIReferenceLibraryViewController = UIReferenceLibraryViewController(term: "word")
        self.present(controller, animated: false)
    }
}

You need to create a Container View. 您需要创建一个容器视图。 There are lots of guides out there like https://naveenr.net/beginning-container-views-in-ios/ 那里有很多指南,如https://naveenr.net/beginning-container-views-in-ios/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM