【发布时间】:2015-04-28 23:18:01
【问题描述】:
我通过 XIB 创建了 CustomViewController。
我还通过不同的 XIB 文件创建了 CustomView,它是 os UIView 的子类。
然后我将 UIView 绑定到 CustomViewController 并将其类设置为 CustomView。
问题在这里:然后我运行这个应用程序我没有看到我在 CustomView XIB 中创建的 CustomView 的内容。
为什么以及如何解决?
我需要在 CustomViewController 中有 CustomView,因为我需要设置这个视图的布局。
我可以从 ViewDidLoad 加载这个 CustomView,但我需要从 XIB 加载它
UIView *v = [[[NSBundle mainBundle] loadNibNamed:@"TopSegmentedControl" owner:self options:nil] firstObject ];
[self.view addSubview:v];
【问题讨论】:
-
我认为这不可能。您也许可以在加载 xib 文件的类上使用 IBDesignable。
-
尝试覆盖 initWithCoder: 在你的 UIView 子类中返回 [[[NSBundle mainBundle]..//etc]];
-
杰夫,我试过了,有错误
标签: ios objective-c uiview nib