nib文件的注册及加载
2015-12-25 12:06
239 查看
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创建没有定义好的布局。
其中,- (NSArray *)loadNibNamed:(NSString *)
options:(NSDictionary *)
的作用是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。
[(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创建没有定义好的布局。
其中,- (NSArray *)loadNibNamed:(NSString *)
nameowner:(id)
owner
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。
相关文章推荐
- android还是iOS
- 安卓开发优化事项
- TDA7496L实测数据
- 简单工厂模式
- NIL、NIL、NULL和NSNULL区别
- ASP.NET中Repeater控件实现分页功能
- 调用WScript.Shell时产生Automation 服务器不能创建对象的错误
- 批处理拷贝东西(从问题里面转载过来的)
- iOS 崩溃调试的使用和技巧总结
- 4.OC仿写知乎客户端
- 视图小问题
- LeetCode - Combination Sum II
- Linux中Samba服务器的编译安装以及配置的宏的写法
- linux命令nohup的使用,ps-aux
- eclipse上用bitbucket git管理代码的部署环境
- lnmp配置信息 4核8g优化
- 一个获取文件绝对路径的sh
- php实现scws中文分词搜索的方法
- angularJS 提示
- LeetCode - Combination Sum