// // SliderPage.m // RedAnt ERP Mobile // // Created by Ray on 14-6-30. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved. // #import "SliderPage.h" #import "FileCache.h" @implementation SliderPage - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } -(void) loadImage { if(self.image==nil) { NSString* file_name=[self.img_url lastPathComponent]; NSData* img_data=[FileCache load_cached_img:file_name loadFrom:self.img_url]; if(img_data!=nil) { UIImage * img =[UIImage imageWithData:img_data]; self.image = img; } else { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:self.img_url]]; dispatch_async(dispatch_get_main_queue(), ^{ if(downloadimg_data!=nil) { [FileCache cache_img:downloadimg_data filename:file_name saveTo:self.img_url]; UIImage * img =[UIImage imageWithData:downloadimg_data]; self.image = img; } }); }); } } } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ @end