Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 异步加载图像_Iphone - Fatal编程技术网

Iphone 异步加载图像

Iphone 异步加载图像,iphone,Iphone,我已经加载了一些图像请告诉我如何使用异步加载图像你是说在后台下载图像吗 Jeff LaMarche的本教程是一个很好的解决方案-利用EGOImageView假设您希望在UIImageView中显示下载的图像,这非常简单(只需使用占位符图像初始化它并设置要下载的图像的URL) 如果您不想显示图像,只想异步下载,请使用EGOImageLoader 只要确保您的类符合EGOImageLoaderObserver协议并实现2个委托方法,您就完成了 - (id)initWithNibName:(NSSt

我已经加载了一些图像请告诉我如何使用异步加载图像

你是说在后台下载图像吗


Jeff LaMarche的本教程是一个很好的解决方案-

利用EGOImageView假设您希望在UIImageView中显示下载的图像,这非常简单(只需使用占位符图像初始化它并设置要下载的图像的URL)

如果您不想显示图像,只想异步下载,请使用EGOImageLoader

只要确保您的类符合EGOImageLoaderObserver协议并实现2个委托方法,您就完成了

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) 
    {
       imageLoader = [EGOImageLoader sharedImageLoader]; // ivar, so we can remove the observer in the dealloc ...
    }
    return self;
}

- (void)dealloc
{
   [imageLoader removeObserver:self];
   [super dealloc];
}

- (void)viewDidLoad
{
   [super viewDidLoad];

   NSString *urlString = @"http://www.wimwauters.be/wp-content/uploads/2011/01/steve-jobs.jpg";
   NSURL *url = [NSURL URLWithString:urlString];
   [imageLoader loadImageForURL:url observer:self];            
}

#pragma mark - EGOImageLoaderObserver

- (void)imageLoaderDidLoad:(NSNotification*)notification 
{
   NSDictionary *userInfo = [notification userInfo];
   UIImage *theImage = [userInfo objectForKey:@"image"];

   // do something with the image, e.g. display it in an ImageView ...
}

- (void)imageLoaderDidFailToLoad:(NSNotification*)notification 
{
   NSDictionary *userInfo = [notification userInfo];
   NSError *error = [userInfo objectForKey:@"error"];
   if (error) 
   {
    // handle the error
   }
}

你能解释一下吗?我得到了json图像,我想加载图像,但非常耗时,所以我不知道如何使用异步方法加载图像