【发布时间】:2011-05-23 00:52:58
【问题描述】:
各位大师,
我如何用另一个 VC 填充主 VC 上的 UIView,我制作简单的 ipadd 应用程序,在主视图上我有 2 个按钮和 2 个 UIview,一个视图是主 UIview,主 UIView 再次有 UIview,我想用另一个 NIB 替换(UIViewController )。如果我单击按钮 1 UIview 将填充 NIB1,如果我单击按钮 2 UIView 将填充 NIB2
这是主要的.h
#import "nib1.h"
#import "nib2.h"
@interface multinibViewController : UIViewController {
IBOutlet UIView *topview;
}
@property (nonatomic,retain) IBOutlet UIView *topview;
-(IBAction)changeNib1;
-(IBAction)changeNib2;
@end
这是实现我必须填写什么代码?
-(IBAction)changeNib1{
}
-(IBAction)changeNib2{
}
我该怎么做才能变成这样?
谢谢,
更新:
ipad的页面布局是这样的
|------------------------------------------------------------|
| This is MainViewController |
| button 1 button 2 |
| |
| |------------------------------------------------------| |
| | This UIView that i want load | |
| | from another NIB / UIViewContoller | |
| | | |
| | | |
| | | |
| | | |
| |------------------------------------------------------| |
| |
| |
| lable Annother_button Annother_Object |
| |
. .
. .
. .
|------------------------------------------------------------|
谢谢 skorulis,这行得通,使用此代码
UIViewController *nib1 = [[UIViewController alloc] initWithNibName:@"nib1" bundle:nil];
[self.topview addSubview:nib1.view];
【问题讨论】: