0

我目前有一个应用程序可以像这样从网络加载图像

[self.userImage setImageWithURL:IMAGEURL placeholderImage:[UIImage imageNamed:@"userPhoto.png"]];

它工作得很好。我仍然想知道是否可以以某种方式保存或缓存图像,以便在用户再次打开应用程序时更快地显示出来。

任何帮助是极大的赞赏。

编辑:

将 SDWebImage 导入我的班级并编译后出现此错误

Ld "DerivedData/Social App/Build/Products/Debug-iphonesimulator/Social App.app/Social App" normal i386
    cd "/Users/iamgretara/Documents/YouTube app "
    setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk "-L/Users/iamgretara/Documents/YouTube app /DerivedData/Social App/Build/Products/Debug-iphonesimulator" "-L/Users/iamgretara/Documents/YouTube app /GDATA" "-F/Users/iamgretara/Documents/YouTube app /DerivedData/Social App/Build/Products/Debug-iphonesimulator" -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist "/Users/iamgretara/Documents/YouTube app /DerivedData/Social App/Build/Intermediates/Social App.build/Debug-iphonesimulator/Social App.build/Objects-normal/i386/Social App.LinkFileList" -Xlinker -objc_abi_version -Xlinker 2 -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=5.0 -framework ImageIO -framework MediaPlayer -framework CoreText -framework AVFoundation -framework SystemConfiguration -framework Security -framework QuartzCore -framework UIKit -framework Foundation -framework CoreGraphics -o "/Users/iamgretara/Documents/YouTube app /DerivedData/Social App/Build/Products/Debug-iphonesimulator/Social App.app/Social App"

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_MKAnnotationView", referenced from:
      l_OBJC_$_CATEGORY_MKAnnotationView_$_WebCache in MKAnnotationView+WebCache.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

错误图片

4

3 回答 3

0

尝试这个:

您可以尝试使用EGOImageLoading 来支持图像缓存。

于 2013-07-15T12:06:59.087 回答
0

当然,您可以自己将文件保存到磁盘并在尝试加载它之前检查它是否存在(全部基于 URL 匹配)。还有一些图书馆会为你做这种事情,比如SDWebImage/ HJCache

于 2013-07-15T11:56:51.300 回答
0

您可以尝试AsyncImageView。它具有内置的缓存支持。

于 2013-07-15T11:57:11.247 回答