1> [[NSBundle mainBundle] loadNibNamed:<#(NSString *)#> owner:<#(id)#> options:<#(NSDictionary *)#>]
Name 参数是文件名(注:不用写后缀),owner参数在不需要事件处理填写nil ,options 参数填写nil;
2> [UINib nibWithNibName:<#(NSString *)#> bundle:<#(NSBundle *)#>];
Name 参数是文件名(注:不用写后缀),bundel 参数默认是mainBundle 直接填nil = mainBundle;
以上返回都是nsarray类型,
加载plist文件:
[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:文件名 ofType:文件后缀]]
[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:文件名.后缀 ofType:nil]]
本文介绍了iOS开发中XIB文件的两种加载方法及PLIST文件的加载方式。XIB加载可通过NSBundle的方法或UINib类实现,而PLIST文件则通过NSBundle获取路径后使用NSArray的类方法进行加载。
1692

被折叠的 条评论
为什么被折叠?



