我通过XIB创建了CustomViewController。
我还通过不同的XIB文件创建了CustomView,即os UIView子类。
然后我把UIView给CustomViewController,然后把它的类设置为CustomView。
问题是:然后我运行这个应用程序,我没有看到我在CustomView XIB中创建的CustomView内容。
我怎么才能修好它?
我需要在CustomView中设置CustomViewController,因为我需要设置这个视图的布局。
我可以从CustomView中加载这个ViewDidLoad,但是我需要从XIB加载它。
UIView *v = [[[NSBundle mainBundle] loadNibNamed:@"TopSegmentedControl" owner:self options:nil] firstObject ];
[self.view addSubview:v];发布于 2015-04-29 00:35:41
您必须将包含在其中的代码放入UIViewController的UIViewController方法中。这是从故事板初始化时调用的初始化方法。假设您已经连接了一个名为myView的插座
- (id)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super initWithCoder:aDecoder])) {
self.myView = [[[NSBundle mainBundle] loadNibNamed:@"TopSegmentedControl" owner:self options:nil] firstObject];
return self;
}
}https://stackoverflow.com/questions/29931595
复制相似问题