【问题标题】:How to load UIViewController XIB inside another ViewController?如何在另一个 ViewController 中加载 UIViewController XIB?
【发布时间】:2019-09-17 12:39:26
【问题描述】:

我正在尝试将UIViewController XIB 添加到现有的ViewController,并尝试创建:

我有一个简单的ViewController,然后我用XIB制作了一个UIView...现在我正在尝试在新的ViewController中使用它:

    let myVC = XIBViewController(nibName: "XIBViewController.xib", bundle: nil)
    self.present(myVC, animated: true, completion: nil)

我怎样才能使它像图像中一样小,而BaseViewController 仍然可见?

【问题讨论】:

  • 你想要它作为流行音乐吗?

标签: ios swift xib viewcontroller


【解决方案1】:

替换(删除.xib

let myVC = P3XIBViewController(nibName: "P3XIBViewController.xib", bundle: nil)

let myVC = P3XIBViewController(nibName: "P3XIBViewController", bundle: nil)

【讨论】:

  • 视图仍然没有显示,我明白了:警告:尝试在 上显示 ,其视图不在窗口层次结构中!
  • 不要在viewDidLoad 中展示它,因为它为时过早
  • 好的,它现在可以工作了......但我怎样才能让它像我的问题中的图像一样小?
猜你喜欢
  • 2013-08-09
  • 1970-01-01
  • 2014-02-13
  • 2014-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
  • 1970-01-01
相关资源
最近更新 更多