Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SDWebImageを1年半使ってみた

 SDWebImageを1年半使ってみた

SDWebImageのTipsです

ninjinkun

April 09, 2014
Tweet

More Decks by ninjinkun

Other Decks in Technology

Transcript

  1. 4%*NBHF$BDIF w σϑΥϧτઃఆ͕͍͚ͯΔ w σΟεΫΩϟογϡͷσϑΥϧτ&YQJSF͸िؒ w ϝϞϦΩϟογϡͷσϑΥϧτ্ݶ͸ͳ͠ w .FNPSZ8BSOJOH࣌ʹϝϞϦΩϟογϡ͸ফ͑Δ w

    σΟεΫΩϟογϡ͸ΞϓϦͷऴྃ࣌ͱόοΫάϥ΢ϯυҠ ߦ࣌ʹ૟আ͞ΕΔ w ͜ͷลΓࣗલͰ࣮૷͢ΔͱۭؾಡΉͷ͕େม
  2. ը૾ΛϑΣʔυͯ͠ද͍ࣔͤͨ͞ w σϑΥϧτͰ͸ը૾͕ͺͬͱදࣔ͞ΕΔ͚ͩ w DPNQMFUFE#MPDLΛ࢖͏ __weak UIImageView *weakImageView = imageView;

    ! [imageView setImageWithURL:imageURL placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { if (cacheType != SDImageCacheTypeMemory) { [UIView transitionWithView:weakImageView duration:0.28 options:UIViewAnimationOptionTransitionCrossDissolve |
 UIViewAnimationOptionCurveLinear |
 UIViewAnimationOptionAllowUserInteraction animations:nil completion:nil]; } }];
  3. ϩʔΧϧͷը૾Λ63-ͰҾ͖ճ͢ w ΧϝϥɺϥΠϒϥϦ͔ΒબΜͩࣸਅʹ63-Λ෇༩ w 4%*NBHF$BDIFʹೖΕΔ w ϑΝΠϧ͕ظݶ෇͖Ͱอଘ͞ΕΔ - (void)imagePickerController:(UIImagePickerController *)picker

    didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *editedImage = (UIImage *)info[UIImagePickerControllerEditedImage]; ! NSString *uuid = [[NSUUID UUID] UUIDString]; NSString *imageURLString = [NSString stringWithFormat:@"njkimage://images/%@.jpg", uuid]; ! [[SDImageCache sharedImageCache] storeImage:editedImage forKey:imageURLString]; ɹɹ// ͜ͷ imageURLString ΛҾ͖ճͤ͹Ͳ͜Ͱ΋ը૾͕ಘΒΕΔ! }
  4. 'BTU*NBHF$BDIF w 8FC͔Βͷμ΢ϯϩʔυػೳ͸෇͍͍ͯͳ͍ w ͜͜Λ4%8FC*NBHFʹ೚ͤΔ - (void)imageCache:(FICImageCache *)imageCache wantsSourceImageForEntity:(id <FICEntity>)entity

    withFormatName:(NSString *)formatName completionBlock: (FICImageRequestCompletionBlock)completionBlock { if ([entity respondsToSelector:@selector(URL)]) { NSURL *URL = [entity performSelector:@selector(URL)]; [[SDWebImageManager sharedManager] downloadWithURL:URL options:SDWebImageRetryFailed
 progress:nil 
 completed:
 ^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) { completionBlock(image); }]; } }