SDWebImageを1年半使ってみた

 SDWebImageを1年半使ってみた

SDWebImageのTipsです

6139fd48daa26e786794598c4a6b546a?s=128

ninjinkun

April 09, 2014
Tweet

Transcript

  1. 4%8FC*NBHFΛ ೥൒࢖ͬͯΈͨ OJOKJOLVO

  2. 4%8FC*NBHF w 8FCը૾ϩʔμʔ w ը૾Ωϟογϡ w 6**NBHF֦ு w Ξχ(*' 8FC1

    IUUQHJUIVCDPNSTTEXFCJNBHF
  3. 4%8FC*NBHF w ͜ͷ೥൒͘Β͍Ͱଟ਺ͷϓϩδΣΫτʹ౤ೖͯ͠
 ໰୊ͳ͠ w ը૾ϑΣονϟʔͷܾఆ൛ͱݴ͑Δ w ྑ͘ϝϯς͞Ε͍ͯͯ։ൃ΋׆ൃ

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

    σΟεΫΩϟογϡ͸ΞϓϦͷऴྃ࣌ͱόοΫάϥ΢ϯυҠ ߦ࣌ʹ૟আ͞ΕΔ w ͜ͷลΓࣗલͰ࣮૷͢ΔͱۭؾಡΉͷ͕େม
  5. (*'BOJNBUJPO 8FC1αϙʔτ w 6**NBHFΞχ(*' 8FC1ͷม׵ؚ͕·Ε͍ͯΔ w 6**NBHF͸ϑΥʔϚοτʹඇґଘ w 4%8FC*NBHFೖΕΔ͚ͩͰΞχ(*'࢖͑Δ w

    ը૾μ΢ϯϩʔμʔͷҬΛ௒͍͑ͯΔʜ w ͚Ͳ࣮૷͕ࣗવͳײ͡ͳͷͰจ۟ͳ͍
  6. ը૾ΛϑΣʔυͯ͠ද͍ࣔͤͨ͞ 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]; } }];
  7. ಡΈࠐΈʹࣦഊͨ݁͠Ռ͕
 Ωϟογϡ͞Εͯ͠·͏ w 4%8FC*NBHF3FUSZ'BJMFEΛࢦఆ͢Δ w 6*5BCMF7JFX$FMM౳ͰҰؾʹը૾Λಡ Ή৔߹͸େ఍෇͚ͯΔ [imageView setImageWithURL:imageURL 


    placeholderImage:nil
 options:SDWebImageRetryFailed];
  8. ϩʔΧϧͷը૾Λ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 ΛҾ͖ճͤ͹Ͳ͜Ͱ΋ը૾͕ಘΒΕΔ! }
  9. ϩʔΧϧͷը૾Λ63-ͰҾ͖ճ͢ w .FNPSZ8BSOJOH࣌ʹղ์͢Δ͜ͱ͕ՄೳʹͳΔ w ඞཁʹͳͬͨΒ·ͨGFUDI͢Ε͹σΟεΫ͔Β෮ ݩ͞ΕΔ w ը૾Λෳ਺બ୒ͯ͠Ξοϓϩʔυ͢Δ৔߹ʹ
 ϝϞϦރׇΛ๷͛Δ

  10. ϩʔΧϧͷը૾Λ63-ͰҾ͖ճ͢ w 6**NBHF7JFX 8FC$BDIFͰදࣔͰ͖Δ w ϩʔΧϧσʔλͷ֬ೝը໘ͱ8FCͷσʔλΛදࣔ ͢Δը໘Λڞ௨ԽͰ͖Δ

  11. .81IPUP#SPXTFS w ը૾ϑϧεΫϦʔϯදࣔϥΠϒϥϦ w ಺෦Ͱ4%8FC*NBHFΛ࢖͍ͬͯΔ w 4%*NBHF$BDIF͕ڞ༻͞ΕΔ w લͷը໘Ͱ։͍͍ͯͨը૾ΩϟογϡΛ࠶ར༻Ͱ͖Δ

  12. 'BTU*NBHF$BDIF w 1BUI͕࡞ͬͨߴ଎ͳը૾දࣔΛ࣮ݱ͢ΔϥΠϒϥϦ w ࣄલʹ࠷దԽͨ͠ը૾Λ࡞ͬͯΩϟογϡ w ΧϦΧϦʹνϡʔχϯά͞Εͨը૾ද͕ࣔՄೳ w νϡʔχϯά෦෼Λ൚༻Խ͍ͯ͠ΔͨΊ"1*͸ෳࡶ w

    ௿εϖοΫ୺຤Ͱେ͖ͳࣸਅΛ͵Δ͵Δಈ͔͍ͨ͠ ͳΒݕ౼͢ΔՁ஋͋Γ
  13. '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); }]; } }
  14. 'BTU*NBHF$BDIF w ͦͷ··ͩͱॏΩϟογϡʹͳΔ w ଞͰ࢖͍ճ͞ͳ͍ͳΒ4%*NBHF$BDIF͸࢖Θͳ͍ Α͏ʹ͢Δ 4%*NBHF$BDIF 'BTU*NBHF$BDIF 4%*NBHF.BOBHFS

  15. ·ͱΊ w 4%8FC*NBHF࠷ߴ w ࣗલͷ࣮૷͸ࣺͯ·͠ΐ͏