1.APP into the loading ad view display:
-(void) initadvview{
Determine if the image already exists Nsarray*paths =nssearchpathfordirectoriesindomains (Nsdocumentdirectory,nsuserdomainmask, YES); NSString*filepath = [[Paths Objectatindex:0] Stringbyappendingpathcomponent:[nsstring stringWithFormat:@"Loading.png"]]; Nsfilemanager*filemanager =[Nsfilemanager Defaultmanager]; BOOL Isdir=FALSE; BOOL Isexit= [FileManager Fileexistsatpath:filepath isdirectory:&Isdir]; if(isexit) {NSLog (@"exist"); _advimage= [[Uiimageview alloc]initwithframe:cgrectmake (0,0, Screen_width, Screen_height)];//[_advimage setimage:[uiimage imagenamed:@ "Loading.png"];[_advimage setimage:[uiimage Imagewithcontentsoffile:filepath]; [Self.window Addsubview:_advimage]; [Self performselector: @selector (removeadvimage) withobject:nil Afterdelay:3]; Dispatch_async (Dispatch_get_global_queue (Dispatch_queue_priority_default,0), ^{ //load launch ad and save to local sandbox, because the saved picture is large, each run is saved, so the note is dropped//[self getloadingimage]; }); }Else{NSLog (@"does not exist"); Dispatch_async (Dispatch_get_global_queue (Dispatch_queue_priority_default,0), ^{
Does not exist then network request, download picture save [self getloadingimage]; }); }}
Picture Removal-(void) removeadvimage{[UIView animatewithduration:0.3fanimations:^{_advimage.transform= Cgaffinetransformmakescale (0.5f,0.5f); _advimage.alpha=0. F; } Completion:^(BOOL finished) {[_advimage Removefromsuperview]; }];}
Network Get PICTURES:
//get the launch ad image and execute the request with background push-(void) getloadingimage{//resolutionCGFloat Scale_screen =[UIScreen Mainscreen].scale; NSLog (@"%.0f%.0f", screen_width*scale_screen,screen_height*Scale_screen); intScalew = (int) screen_width*Scale_screen; intScaleh = (int) screen_height*Scale_screen; NSString*URLSTR = [NSString stringWithFormat:@"Http://api.meituan.com/config/v1/loading/check.json?app_name=group&app_version=5.7&ci=1&city_id=1 &client=iphone&moviebundleversion=100&msid=48e2b810-805d-4821-9cdd-d5c9e01bc98a2015-07-15-15-51824 &platform=iphone&resolution=%d%@%d&userid=10086&utm_campaign=agroupbgroupd100fa20141120nanning __m1__leftflow___ab_pindaochangsha__a__leftflow___ab_gxtest__gd__leftflow___ab_gxhceshi__nostrategy__leftflow_ __ab_i550poi_ktv__d__j___ab_chunceshishuju__a__a___ab_gxh_82__nostrategy__leftflow___ab_i_group_5_3_ Poidetaildeallist__a__b___b1junglehomepagecatesort__b__leftflow___ab_gxhceshi0202__b__a___ab_ Pindaoquxincelue0630__b__b1___ab_i550poi_xxyl__b__leftflow___ab_i_group_5_6_searchkuang__a__leftflow___i_group _5_2_deallist_poitype__d__d___ab_pindaoshenyang__a__leftflow___ab_b_food_57_purepoilist_extinfo__a__a___ab_ Waimaiwending__a__a___ab_waimaizhanshi__b__b1___ab_i550poi_lr__d__leftflow___ab_i_group_5_5_onsite__b__b___ab_ Xinkeceshi__b__leftflowghomepage&utm_Content=4b8c0b46f5b0527d55ea292904fd7e12e48fb7bea8df50bfe7828af7f20bb08d&utm_medium=iphone&utm_source= appstore&utm_term=5.7&uuid=4b8c0b46f5b0527d55ea292904fd7e12e48fb7bea8df50bfe7828af7f20bb08d& version_name=5.7", Scalew,@"%2a", Scaleh]; [[Networksingleton Sharedmanager] Getadvloadingimage:nil url:urlstr successblock:^(id responsebody) {NSLog (@"get startup ad picture Success"); Nsmutablearray*dataarray = [Responsebody objectforkey:@"Data"]; NSLog (@"dataarray:%@", DataArray); Dispatch_async (Dispatch_get_global_queue (Dispatch_queue_priority_default,0), ^{ if(dataarray.count>0) {NSData*data = [NSData datawithcontentsofurl:[nsurl urlwithstring:[dataarray[0] Objectforkey:@"IMAGEURL"]]]; UIImage*image =[UIImage Imagewithdata:data]; Nsarray*paths =nssearchpathfordirectoriesindomains (Nsdocumentdirectory,nsuserdomainmask, YES); NSString*filepath = [[Paths Objectatindex:0] Stringbyappendingpathcomponent:[nsstring stringWithFormat:@"Loading.png"]];//Save the name of the file//BOOL result = [Uiimagepngrepresentation () Writetofile:filepath Atomically:yes];//Save succeeded will return YesNSLog (@"paths:%@%@", Paths,filepath); [Uiimagepngrepresentation (image) Writetofile:filepath Atomically:yes]; } }); } Failureblock:^ (NSString *error) {NSLog (@"get start ad picture failed:%@", error); }];}
2. Refresh the custom GIF image:
-(void) setuptableview{//Add a drop-down animated picture//Setting the drop-down refresh callback[Self.tableview addgifheaderwithrefreshingtarget:self refreshingaction: @selector (refreshdata)]; //set up an animated picture of a normal stateNsmutablearray *idleimages =[Nsmutablearray array]; for(Nsuinteger i =1; i<= -; ++i) {UIImage*image = [UIImage imagenamed:[nsstring stringWithFormat:@"Dropdown_anim__000%zd", I]]; [Idleimages Addobject:image]; } [Self.tableView.gifHeader setimages:idleimages forstate:mjrefreshheaderstateidle]; //set up an animated picture of the state that is about to refreshNsmutablearray *refreshingimages =[Nsmutablearray array]; for(Nsinteger i =1; i<=3; i++) {UIImage*image = [UIImage imagenamed:[nsstring stringWithFormat:@"Dropdown_loading_0%zd", I]]; [Refreshingimages Addobject:image]; } [Self.tableView.gifHeader setimages:refreshingimages forstate:mjrefreshheaderstatepulling]; //set the animated picture that is being refreshed[Self.tableView.gifHeader setimages:refreshingimages forstate:mjrefreshheaderstaterefreshing]; //go to refresh status now[Self.tableView.gifHeader beginrefreshing];}
"American group" app learns to record knowledge points