nib文件的注册及加载
1,注册
[(UIView *)view registerNib:[UINib nibWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle] forCellReuseIdentifier:(NSString *)identifier];
2,加载
cell = [[[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil] lastObject];
自定义的空间一般采用加载nib文件的形式创建,用new创建没有定义好的布局。
options:(NSDictionary *)
options
的作用是Unarchives the contents of a nib file located in the receiver's bundle.
3,NSBundle的作用
作用:NSBundle用来管理项目中的资源文件,NSBundle实体可以定位项目中用到的资源,动态加载或者卸载可执行代码,起到辅助定位的功能。个人觉得英文版更能解释这个概念。
NSBundle : An NSBundle object represents a location in the file system that groups code and resources that can be used in a program. NSBundle objects locate program resources, dynamically load and unload executable code, and assist in localization.
若为nil,则默认为mainBunble。