程式執行起來,歡迎介面之後,會進入AppDelegate,因此我們可以在application: didFinishLaunchingWithOptions:新增程式碼完成想要的效果。連網獲取圖片可以用第三方SDWebImage實現,所以需要先將第三方資料夾匯入。因為顯示廣告的頁面是在歡迎介面基礎上顯示的,因此可以直接利用LaunchScreen.xib中得view,在上面新增一個UIImageView顯示圖片,然後將其加在window上,並顯示在最上層。廣告圖片顯示之後,再將view移除掉,顯示程式的主介面。程式碼如下所示:
#import "AppDelegate.h"
#import "UIImageView+WebCache.h"
@interface AppDelegate ()
@property (strong, nonatomic) UIView *lunchView;
@end
@implementation AppDelegate
@synthesize lunchView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window makeKeyAndVisible];
lunchView = [[NSBundle mainBundle ]loadNibNamed:@"LaunchScreen" owner:nil options:nil][0];
lunchView.frame = CGRectMake(0, 0, self.window.screen.bounds.size.width, self.window.screen.bounds.size.height);
[self.window addSubview:lunchView];
UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 50, 320, 300)];
NSString *str = @"http://www.jerehedu.com/images/temp/logo.gif";
[imageV sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"default1.jpg"]];
[lunchView addSubview:imageV];
[self.window bringSubviewToFront:lunchView];
[NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(removeLun) userInfo:nil repeats:NO];
return YES;
}
-(void)removeLun
{
[lunchView removeFromSuperview];
程式執行起來,歡迎介面之後,會進入AppDelegate,因此我們可以在application: didFinishLaunchingWithOptions:新增程式碼完成想要的效果。連網獲取圖片可以用第三方SDWebImage實現,所以需要先將第三方資料夾匯入。因為顯示廣告的頁面是在歡迎介面基礎上顯示的,因此可以直接利用LaunchScreen.xib中得view,在上面新增一個UIImageView顯示圖片,然後將其加在window上,並顯示在最上層。廣告圖片顯示之後,再將view移除掉,顯示程式的主介面。程式碼如下所示:
#import "AppDelegate.h"
#import "UIImageView+WebCache.h"
@interface AppDelegate ()
@property (strong, nonatomic) UIView *lunchView;
@end
@implementation AppDelegate
@synthesize lunchView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window makeKeyAndVisible];
lunchView = [[NSBundle mainBundle ]loadNibNamed:@"LaunchScreen" owner:nil options:nil][0];
lunchView.frame = CGRectMake(0, 0, self.window.screen.bounds.size.width, self.window.screen.bounds.size.height);
[self.window addSubview:lunchView];
UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 50, 320, 300)];
NSString *str = @"http://www.jerehedu.com/images/temp/logo.gif";
[imageV sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"default1.jpg"]];
[lunchView addSubview:imageV];
[self.window bringSubviewToFront:lunchView];
[NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(removeLun) userInfo:nil repeats:NO];
return YES;
}
-(void)removeLun
{
[lunchView removeFromSuperview];
}