我在 xib 中设计了我的自定义 View 。我有 CustomView.h/m
+ CustomView.xib
.在 xib 文件中,我将 View 类设置为 CustomView。
现在我想在其他 xib 中使用这个 View 。我创建了另一个 xib,添加了 View 并将其设置为 CustomView
,但它没有加载。
如何正确加载我的 CustomView?
最佳答案
简短的回答:是的。
You can use
CustomView.h/m
in as many.XIB
files as you see fit, including.storyboard
问题在于如何加载第二个 View 。
if let navigationController = self.navigationController {
let sb = UIStoryboard(name: "Main", bundle: nil)
if let vc = sb.instantiateViewControllerWithIdentifier("id") as? UIViewController {
navigationController.pushViewController(vc, animated: true)
}
}
看:
关于ios:在xib中加载自定义 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31156046/