62库

您现在的位置是:首页 > 前端开发 > Html/Css > 正文

Html/Css

IOS NSBundle使用(访问文件夹)

Admin2023-11-11Html/Css85

NSBundle的相关信息

1.一个NSBundle代表一个文件夹,利用NSBundle能访问对应的文件夹

2.利用mainBundle就可以访问软件资源包中的任何资源

3.模拟器应用程序的安装路径:

/Users/aplle/资源库/Application Support/iPhone Simulator/7.1/Applications

代码:访问plist文件

NSString *path=[[NSBundle mainBundle]pathForResource:@"statuses.plist" ofType:nil];

代码 :访问Xib

+(instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *ID=@"tg";
MJtgCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
if(cell==nil)
{
//从xib中加载cell
cell=[[[NSBundle mainBundle]loadNibNamed:@"MJtgCell" owner:nil options:nil]lastObject];
}
return cell;}

发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~