AppDelegate.mapp
#import "AppDelegate.h" #import "XMGAdViewController.h" @interface AppDelegate () @end @implementation AppDelegate // 程序启动的时候就会调用 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 1.建立窗口 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; // 2.设置窗口根控制器 XMGAdViewController *adVc = [[XMGAdViewController alloc] init]; // init -> initWithNibName 1.首先判断有没有指定nibName 2.判断下有没有跟类名同名xib self.window.rootViewController = adVc; // 3.显示窗口 1.成为UIApplication主窗口 2. [self.window makeKeyAndVisible]; return YES; }
XMGAdViewController.miphone
import "XMGAdViewController.h" @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]; // 加载广告数据 } // 设置启动图片 - (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"]; } }
/***********屏幕适配*************/ #define XMGScreenW [UIScreen mainScreen].bounds.size.width #define XMGScreenH [UIScreen mainScreen].bounds.size.height #define iphone6P (XMGScreenH == 736) #define iphone6 (XMGScreenH == 667) #define iphone5 (XMGScreenH == 568) #define iphone4 (XMGScreenH == 480) /***********屏幕适配*************/