我是iphone的新用户,我在main.storyboard文件中成功实现了.xib文件(图1)但无法在同一个.storyboard文件的下一个视图中导入相同的.xib文件(图2其他视图)相同的.storyboard文件)。请建议我如何在其他视图上导入相同的.xib文件。
ViewController.m(影响main.storyboard)
#import "ViewController.h"
#import "CustomView.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CustomView *customView = [CustomView customView];
[self.view addSubview:customView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
答案 0 :(得分:1)
在nextView控制器的viewdidload中添加以下行 -
UIView *customView= [[[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil] lastObject];
[_containerView addSubview:customView];
答案 1 :(得分:1)
只需转到.storyboard的下一个视图页面,点击即可 身份检查员 - > class - >的ViewController
它将在您的同一.storyboard文件的下一个视图中反映常见的xib文件