性能优化总结

2016-08-27  本文已影响18人  KeepFighting
  1. [UIImage imageWithContentsOfFile:photoFilePath]
    �通过 imageWithContentsOfFile: 加载的图片系统不会缓存;可以通过GCD�加载提高性能,用字典自己缓存
if(!thumbImage) {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
      UIImage *image = [UIImage imageWithContentsOfFile:photoFilePath];
        UIGraphicsBeginImageContext(CGSizeMake(180.0f, 120.0f));
        [image drawInRect:CGRectMake(0, 0, 180.0f, 120.0f)];
        thumbImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
      dispatch_async(dispatch_get_main_queue(), ^{
        [self.photosCache setObject:thumbImage forKey:photoName];
        cell.photoView.image = thumbImage;
      });
    });
  }
  

2.关于UIKit优化
http://www.jianshu.com/p/619cf14640f3

上一篇 下一篇

猜你喜欢

热点阅读