将另一个 NIB 加载到 UIVIEW 的一个子视图中
我有一个简单的问题,我在整个网站上看不到它的答案,
一个以 UIView 作为主要内容的 XIB 文件,
其中有另一个连接到一个 IBoutlet 的 UIView,这样我可以稍后分配它来加载视图另一个 XIB 文件。该分配不起作用..它仍然是空白...
@interface Subclass : UIViewController {
UIView *view1;
}
@property (nonatomic,retain) IBOutlet UIView *view1;
@end
我将 view1 链接到 xib 文件中的子视图 在 initWithNibName 的实现中,我正在加载其他 XIB 文件并使用它的视图并将其分配给 view1。但这仍然不起作用...
detailControler = [[XibViewControler alloc] initWithNibName:@"XibViewControler" bundle:nil];
//one aproach
[self.view1 addSubview: detailControler.view];
//another aproach
[self setView1:detailControler.view];
如果我以编程方式将子视图添加到 [self.view addSubview:detailControler.view] 并为其设置一个框架,它将全屏显示,并隐藏原始视图。
我也有不同的方法但不起作用 如何加载多个视图使用 UISegmentedVIew 时点击每个按钮
I have a simple question that I couldn't see it answered on the whole site,
One XIB file that has a UIView as the main,
in it has another UIView that's connected to one IBoutlet so I can assign it later to load a view from another XIB file. That assignment doesn't work.. it remains blank...
@interface Subclass : UIViewController {
UIView *view1;
}
@property (nonatomic,retain) IBOutlet UIView *view1;
@end
i linked view1 to the subview in the xib file
in implementation in initWithNibName I'm loading Other XIB file and use it's view and assigning it to the view1. Still this doesn't work...
detailControler = [[XibViewControler alloc] initWithNibName:@"XibViewControler" bundle:nil];
//one aproach
[self.view1 addSubview: detailControler.view];
//another aproach
[self setView1:detailControler.view];
If I'm adding the subview programaticaly to [self.view addSubview:detailControler.view] and set a frame to it, it will go fullscreen, and hide the original view.
I also had a different approach that didn't work
How to load multiple views on each button tap when using a UISegmentedVIew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我通常在另一个视图中设置
UIView
的方式,尽管我不完全确定这是否是最佳实践或类似的做法:希望有帮助!
This is how I usually set up a
UIView
inside another view, although I'm not entirely sure if it's best practice or anything like that:Hope that Helps!