首页 > 代码库 > 加载广告界面数据
加载广告界面数据
// XMGAdViewController.m#import "XMGAdViewController.h"#import <AFNetworking/AFNetworking.h>/* 1.广告业务逻辑 2.占位视图思想:有个控件不确定尺寸,但是层次结构已经确定,就可以使用占位视图思想 3.屏幕适配.通过屏幕高度判断 */#define code2 @"phcqnauGuHYkFMRquANhmgN_IauBThfqmgKsUARhIWdGULPxnz3vndtkQW08nau_I1Y1P1Rhmhwz5Hb8nBuL5HDknWRhTA_qmvqVQhGGUhI_py4MQhF1TvChmgKY5H6hmyPW5RFRHzuET1dGULnhuAN85HchUy7s5HDhIywGujY3P1n3mWb1PvDLnvF-Pyf4mHR4nyRvmWPBmhwBPjcLPyfsPHT3uWm4FMPLpHYkFh7sTA-b5yRzPj6sPvRdFhPdTWYsFMKzuykEmyfqnauGuAu95Rnsnbfknbm1QHnkwW6VPjujnBdKfWD1QHnsnbRsnHwKfYwAwiu9mLfqHbD_H70hTv6qnHn1PauVmynqnjclnj0lnj0lnj0lnj0lnj0hThYqniuVujYkFhkC5HRvnB3dFh7spyfqnW0srj64nBu9TjYsFMub5HDhTZFEujdzTLK_mgPCFMP85Rnsnbfknbm1QHnkwW6VPjujnBdKfWD1QHnsnbRsnHwKfYwAwiuBnHfdnjD4rjnvPWYkFh7sTZu-TWY1QW68nBuWUHYdnHchIAYqPHDzFhqsmyPGIZbqniuYThuYTjd1uAVxnz3vnzu9IjYzFh6qP1RsFMws5y-fpAq8uHT_nBuYmycqnau1IjYkPjRsnHb3n1mvnHDkQWD4niuVmybqniu1uy3qwD-HQDFKHakHHNn_HR7fQ7uDQ7PcHzkHiR3_RYqNQD7jfzkPiRn_wdKHQDP5HikPfRb_fNc_NbwPQDdRHzkDiNchTvwW5HnvPj0zQWndnHRvnBsdPWb4ri3kPW0kPHmhmLnqPH6LP1ndm1-WPyDvnHKBrAw9nju9PHIhmH9WmH6zrjRhTv7_5iu85HDhTvd15HDhTLTqP1RsFh4ETjYYPW0sPzuVuyYqn1mYnjc8nWbvrjTdQjRvrHb4QWDvnjDdPBuk5yRzPj6sPvRdgvPsTBu_my4bTvP9TARqnam"@interface XMGAdViewController ()@property (weak, nonatomic) IBOutlet UIImageView *launchImageView;@property (weak, nonatomic) IBOutlet UIView *adContainView;@end@implementation XMGAdViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. // 设置启动图片 [self setupLaunchImage]; // 加载广告数据 => 拿到活时间 => 服务器 => 查看接口文档 1.判断接口对不对 2.解析数据(w_picurl,ori_curl:跳转到广告界面,w,h) => 请求数据(AFN) [self loadAdData];}/* http://mobads.baidu.com/cpro/ui/mads.php ?= */#pragma mark - 加载广告数据- (void)loadAdData{ // unacceptable content-type: text/html" 响应头 // 1.创建请求会话管理者 AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager]; // 2.拼接参数 NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; parameters[@"code2"] = code2; // 3.发送请求 [mgr GET:@"http://mobads.baidu.com/cpro/ui/mads.php" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { // 请求数据 -> 解析数据 -> 展示数据 NSLog(@"%@",responseObject); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSLog(@"%@",error); }]; }// 设置启动图片- (void)setupLaunchImage{ // 6p:LaunchImage-800-Portrait-736h@3x.png // 6:LaunchImage-800-667h@2x.png // 5:LaunchImage-568h@2x.png // 4s:LaunchImage@2x.png if (iphone6P) { // 6p self.launchImageView.image = [UIImage imageNamed:@"LaunchImage-800-Portrait-736h@3x"]; } else if (iphone6) { // 6 self.launchImageView.image = [UIImage imageNamed:@"LaunchImage-800-667h"]; } else if (iphone5) { // 5 self.launchImageView.image = [UIImage imageNamed:@"LaunchImage-568h"]; } else if (iphone4) { // 4 self.launchImageView.image = [UIImage imageNamed:@"LaunchImage-700"]; } @end
加载广告界面数据
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。