Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
974 views
in Technique[技术] by (71.8m points)

ios - How to install SDWebImage

I need to manage photos in my app and have read much about SDWebImage framework which seems to be the best way to go. However I am finding it incredibly difficult to install. I dont know Ruby and have never used a podfile, so am installing it by downloading the latest SDWebImagefolder & framework and adding them to my project. However when I try to import into my viewcontroller using the suggested imports:

#import <SDWebImage/UIImageView+WebCache.h>
#import "UIImageView+WebCache.h"

I get a file not found with on the #import then if I change this to "SDWebImage/UIImageView+WebCache.h" as suggested I get a file not found on the: #import UIImageView+WebCache.h even though I can clearly see it when I open the SDWebImage folder in my project! I'm guessing that these errors also lead to a not found error when I try to use the sd_setImageWithUrl method.

Here's a screen shot of my project:

enter image description here

I hope I can get some help with this as the framework looks to have very good functionality. Any help very much appreciated. Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When you add the SDWebImage folder in your project then select following option. To add copy of your folder to the destination project and Create groups.

and then you have to write just like

#import "UIImageView+WebCache.h"

And make sure that you are adding to all the targets that you want to use that library.

enter image description here

Documentation at Github :

Add the SDWebImage project to your project

  • Download and unzip the last version of the framework from the download page
  • Right-click on the project navigator and select "Add Files to "Your Project":
  • In the dialog, select SDWebImage.framework:
  • Check the "Copy items into destination group's folder (if needed)" checkbox

Or you can use cocoa pods as other answer suggested.

EDIT : EXAMPLE :

[self.imageView sd_setImageWithURL:[NSURL URLWithString:"yoururl.png"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...