How to load ads dynamically in the Welcome screen in iOS

Source: Internet
Author: User

当我们打开一款应用程序的时候,首先映入眼帘的往往并不是程序的主界面,而是经过精心设计的欢迎界面,这个界面通常会停留几秒钟,然后消失。看似很平常的一个小小的欢迎界面,其实还大有讲究。一 为什么会有欢迎界面呢?这是因为程序在启动的过程中需要消耗一些时间,那么在加载出现主界面之前,会出现短暂的黑屏,这实在是很糟糕的一件事情,会给用户一个非常不好的体验。为了缓解用户等待过程中心理的不适与烦躁,欢迎界面闪亮登场了!

The welcome interface to replace the black screen waiting, can effectively cover up the time-consuming blocking background operations, but also to show users effective information, is a very good transition program. But some procedures to make the welcome interface into a advertising version, wasting more time users, let users feel bored, the program itself has lost interest in the function, this practice is very unwise. So the question is, how many types of welcome interface are there?
  
Ii. Categories of Welcome interface
There are many kinds of welcome interface, which can be divided into two kinds: static and dynamic.
Static welcome interface is usually relatively concise, generally will be placed a very beautiful picture, may be a company or product propaganda map, may also be an advertising map, give me the deepest impression is a chat software on the birthday of the Open, welcome interface unexpectedly is a write your name of the birthday blessing picture, let people feel very warm.
Dynamic welcome interface to be more cool and beautiful, style is more rich, some Internet-loaded ads, and some like a very flashy book, you can slide the page, there is a small game, some beautiful text with wonderful music, there may be a funny animation.

Three welcome interface using Launchimage
For IOS7 and above, Apple provides a launchimage to achieve the welcome interface, when developing only need to design the corresponding size of the picture to drag to the corresponding state location.

The size of the Welcome screen is:
iphone vertical screen 640*960 640*1136
ipad vertical screen 768*1024 1536*2048
ipad Horizontal screen 1024x768 2028*1536
IOS9 appears After that, Apple launched the Launchscreen.storyboard to do a welcome interface, if you want to launchimage to do the welcome interface, Perfect fit IOS7 and IOS8, how should it be done?
First, you need to delete Launchscreen.storyboard, otherwise IOS9 will call it automatically. Then find Images.xcassets, click the + sign below, select New Launch image, and then follow the corresponding requirements to put the corresponding size picture, and the previous operation is exactly the same. The

Four Welcome interface uses Launchscreen.storyboard
IOS9 to add many new features, such as Launchscreen.storyboard
, Size classes, and so on. When the program starts, it automatically calls Launchscreen.storyboard, so you can add the controls you want to display on this xib and add constraints to display them.

as shown, because the above control is a constraint added in the case of any W and any H, it can be fitted on any device of any size. In order to ensure a more perfect effect, xib in the picture we can use the images.xcassets to set, so that the different devices can automatically select the corresponding size of the picture, to achieve better results.

Loading ads in the five Welcome screen
There are many applications open, the Welcome screen will be loaded with a network to get the ad image or display a set of animation, how does this effect? Here is a simple way to implement loading ads.
The program runs up and the Welcome interface goes into Appdelegate, so we can do the desired effect in Application:didfinishlaunchingwithoptions: Add code. Because the page that displays the ad is displayed on the Welcome screen, you can use the Launchscreen.storybroad view to add a uiimageview display image on top of it, and then put it on the window and display it on top. After the ad image is displayed, the view is removed and the program's main screen is displayed. The code looks like this:
  

////APPDELEGATE.M//program start////Created by Apple on 16/4/19.//Copyright 2016 Liuyugang. All rights reserved.//#import "AppDelegate.h" #import "RootViewController.h"  @interface appdelegate ()@property(nonatomic,Strong)UIView*lunchview;@end @implementation appdelegate - (BOOL) Application: (uiapplication*) Application Didfinishlaunchingwithoptions: (nsdictionary*) Launchoptions { Self. Window= [[UIWindowAlloc] Initwithframe:[[uiscreen mainscreen] bounds];//Override point for customization after application launch.     Self. Window. BackgroundColor= [UicolorWhitecolor]; [ Self. WindowMakekeyandvisible]; Rootviewcontroller *root = [[Rootviewcontroller alloc]init]; Self. Window. Rootviewcontroller= root; Self. Lunchview= [[UIViewAlloc]init]; Self. Lunchview. Frame= CGRectMake (0,0, Self. Window. screen. Bounds. Size. Width, Self. Window. screen. Bounds. Size. Height); [ Self. WindowAddsubview: Self. Lunchview];Uiimageview*imagev = [[UiimageviewAlloc] Initwithframe:cgrectmake ( -, -, the, -)];UIImage*img = [UIImageimagenamed:@"123.jpg"]; Imagev. Image= img; [ Self. LunchviewAddsubview:imagev]; [ Self. WindowBringsubviewtofront: Self. Lunchview]; [Nstimer Scheduledtimerwithtimeinterval:3Target SelfSelector@selector(removelunch) UserInfo:NilRepeatsNO];return YES;} -(void) removelunch{[ Self. LunchviewRemovefromsuperview];}

Six
1) program to start the displayed Picture (Guide diagram)

2) Advertising Images

3) Program normal operation display picture

How to load ads dynamically in the Welcome screen in iOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.