现在的位置: 首页 > 综合 > 正文

IOS获取图片方法,避免内存过大闪退

2018年02月02日 ⁄ 综合 ⁄ 共 218字 ⁄ 字号 评论关闭
建议使用该方法获取图片
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"sun"  ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
  
不要使用下面的方法,图片过大容易造成内存溢出
UIImage *image = [UIImage imageNamed:@"sun.png"];

抱歉!评论已关闭.