1.APP进入加载广告视图展示:

-(void)initAdvView{

// 判断图片是否已经存在
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:] stringByAppendingPathComponent:[NSString stringWithFormat:@"loading.png"]]; NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDir = FALSE;
BOOL isExit = [fileManager fileExistsAtPath:filePath isDirectory:&isDir];
if (isExit) {
NSLog(@"存在");
_advImage = [[UIImageView alloc]initWithFrame:CGRectMake(, , 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:]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, ), ^{
//加载启动广告并保存到本地沙盒,因为保存的图片较大,每次运行都要保存,所以注掉了
// [self getLoadingImage];
});
}else{
NSLog(@"不存在");
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, ), ^{
// 不存在则网络请求,下载图片保存
[self getLoadingImage];
});
}
}

// 图片移除
-(void)removeAdvImage{
[UIView animateWithDuration:0.3f animations:^{
_advImage.transform = CGAffineTransformMakeScale(0.5f, 0.5f);
_advImage.alpha = .f;
} completion:^(BOOL finished) {
[_advImage removeFromSuperview];
}];
}

网络获取图片:

//获取启动广告图片,采用后台推送时执行请求
-(void)getLoadingImage{
//分辨率
CGFloat scale_screen = [UIScreen mainScreen].scale;
NSLog(@"%.0f %.0f",screen_width*scale_screen,screen_height*scale_screen);
int scaleW = (int)screen_width*scale_screen;
int scaleH = (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(@"获取启动广告图片成功");
NSMutableArray *dataArray = [responseBody objectForKey:@"data"];
NSLog(@"dataArray:%@",dataArray);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, ), ^{
if (dataArray.count>) {
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[dataArray[] objectForKey:@"imageUrl"]]];
UIImage *image = [UIImage imageWithData:data]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *filePath = [[paths objectAtIndex:] stringByAppendingPathComponent:[NSString stringWithFormat:@"loading.png"]]; // 保存文件的名称
// BOOL result = [UIImagePNGRepresentation() writeToFile: filePath atomically:YES]; // 保存成功会返回YES
NSLog(@"paths:%@ %@",paths,filePath);
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES]; }
}); } failureBlock:^(NSString *error){
NSLog(@"获取启动广告图片失败:%@",error);
}];
}

2.刷新自定义gif图片:

-(void)setUpTableView{
//添加下拉的动画图片
//设置下拉刷新回调
[self.tableView addGifHeaderWithRefreshingTarget:self refreshingAction:@selector(refreshData)]; //设置普通状态的动画图片
NSMutableArray *idleImages = [NSMutableArray array];
for (NSUInteger i = ; i<=; ++i) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_anim__000%zd",i]];
[idleImages addObject:image];
}
[self.tableView.gifHeader setImages:idleImages forState:MJRefreshHeaderStateIdle]; //设置即将刷新状态的动画图片
NSMutableArray *refreshingImages = [NSMutableArray array];
for (NSInteger i = ; i<=; i++) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_loading_0%zd",i]];
[refreshingImages addObject:image];
}
[self.tableView.gifHeader setImages:refreshingImages forState:MJRefreshHeaderStatePulling]; //设置正在刷新是的动画图片
[self.tableView.gifHeader setImages:refreshingImages forState:MJRefreshHeaderStateRefreshing]; //马上进入刷新状态
[self.tableView.gifHeader beginRefreshing];
}

"美团"APP学习记录知识点的更多相关文章

  1. react+redux+react-router+node.js 开发实时聊天App 学习记录

    一.课程导学 1.React 主要解决的是UI层的问题,应用的状态需要借助Redux等状态管理. 2.前端React  +  antd-mobile UI组件库 + Redux 状态管理库 + Rea ...

  2. 美团App用户界面分析

    关于美团 美团网成立于2010年,合并前是中国销售额最大的独立团购 App.美团网2014年全年交易额突破460亿元,较去年增长180%以上,市场份额占比超60%,用户数超2亿~ 美团 App 用户界 ...

  3. ASP.NETCore学习记录(一)

    ASP.NETCore学习记录(一) asp.net core介绍  Startup.cs  ConfigureServices  Configure  0. ASP.NETCore 介绍 ASP.N ...

  4. 前端学习记录 week 1

    前端学习记录 week 1 基础知识 CSS盒模型 所有HTML元素可以看作盒子,在CSS中,"box model"这一术语是用来设计和布局时使用.CSS盒模型本质上是一个盒子,封 ...

  5. 写一个TODO App学习Flutter本地存储工具Moor

    写一个TODO App学习Flutter本地存储工具Moor Flutter的数据库存储, 官方文档: https://flutter.dev/docs/cookbook/persistence/sq ...

  6. UWP学习记录5-设计和UI之控件和模式2

    UWP学习记录5-设计和UI之控件和模式2 1.应用栏和命令栏 CommandBar 控件是一款通用.灵活.轻型的控件,可显示复杂内容(如图像或文本块)以及简单的命令(如 AppBarButton.A ...

  7. UWP学习记录4-设计和UI之控件和模式1

    UWP学习记录4-设计和UI之控件和模式1 1.控件和事件简介 在 UWP 应用开发中,控件是一种显示内容或支持交互的 UI 元素. 控件是用户界面的构建基块. 我们提供了超过 45 种控件供你使用, ...

  8. UWP学习记录1-开端

    UWP学习记录1-开端 1.背景 针对不同基础的人,学习的路线自然是不同的.这篇文章记录的是我个人的学习路线,或者说笔记.我对自己的技术状态的定义是: A.有很好的windows平台编程基础: B.有 ...

  9. AndroidStudio学习记录

    AndroidStudio学习记录 1. 插件的使用. plugins.jetbrains.com插件网站. 2. 目录介绍: 1.Studio中有Project和Module的概念,前面说到Stud ...

随机推荐

  1. 【模板】多标记 LCT

    代码如下 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int mod = 51061 ...

  2. 持久化存储与HTTP缓存

    本文主要学习一下一些高级的HTTP知识,例如Session LocalStorage Cache-Control Expires ETag 其实主要就是涉及到了持久化存储与缓存的技术 在此之前已经学习 ...

  3. gitlab断电

    断电重启以后 会出现2019-06-26_05:47:42.71382 HINT: If you're sure there are no old server processes still run ...

  4. maven 项目下 Maven Dependencies 下列表为空

    问题如题,如下图: 解决: 选中 Maven Dependencies ,右键 属性 如下图: 把   resolve dependencies from workspace projects   这 ...

  5. 题解 最长上升子序列 LIS

    最长上升子序列 LIS Description 给出一个 1 ∼ n (n ≤ 10^5) 的排列 P 求其最长上升子序列长度 Input 第一行一个正整数n,表示序列中整数个数: 第二行是空格隔开的 ...

  6. 网络编程-UDP echo server

    1. UDP简介 UDP 和TCP 的区别包括 1. 面向字节流和面向报文 2. TCP必须要建立连接后才能进行数据交换,但是UDP则并没有连接的建立和释放过程.面向字节流说明,tcp报文段(segm ...

  7. oracle rowtype

    v_customer customerinfo%rowtype; select * into v_customer from customerinfo where guid = v_loan.cust ...

  8. 通过JS完成电梯动画效果

    实习单位要求做一个在Vue项目中比较能适配的来反映货梯当前状况的页面效果 用JS写了一个 <!DOCTYPE html> <html> <head> <met ...

  9. html5文件夹上传下载组件

    我们平时经常做的是上传文件,上传文件夹与上传文件类似,但也有一些不同之处,这次做了上传文件夹就记录下以备后用. 这次项目的需求: 支持大文件的上传和续传,要求续传支持所有浏览器,包括ie6,ie7,i ...

  10. 2019牛客暑期多校训练营(第二场)A 数学

    题意 eddy走一个长度为\(n\)的环,每次能往前或往后走一步,问走到\(m\)点恰好走完所有点至少一次的概率,前\(i\)个询问的答案要乘起来 分析 \(n=1,m=0\),答案为\(1\) \( ...