程序启动时候自定义的显示页面

//PRPSplashScreenDelegate.h
@class PRPSplashScreen;
@protocol PRPSplashScreenDelegate<NSObject>
@optional
- (void)splashScreenDidAppear:(PRPSplashScreen*)splashScreen;
- (void)splashScreenWillDisappear:(PRPSplashScreen*)splashScreen;
- (void)splashScreenDidDisappear:(PRPSplashScreen*)splashScreen;
@end
//PRPSplashScreen.h
#import "PRPSplashScreenDelegate.h"
@interface PRPSplashScreen : UIViewController {}
@property (nonatomic, retain) UIImage*splashImage;
@property (nonatomic, assign) BOOLshowsStatusBarOnDismissal;
@property (nonatomic, assign) IBOutletid<PRPSplashScreenDelegate>delegate;
- (void)hide;
@end


//PRPSplashScreen.m
#import "PRPSplashScreen.h"
@implementation PRPSplashScreen
@synthesize splashImage;
@synthesize showsStatusBarOnDismissal;
@synthesize delegate;
- (void)dealloc {
    [splashImagerelease], splashImage = nil;
    [superdealloc];
}
- (void)viewDidUnload {
    [superviewDidUnload];
   self.splashImage = nil;
}
- (void)loadView {
    UIImageView *iv= [[UIImageView alloc] initWithImage:self.splashImage];
   iv.autoresizingMask = UIViewAutoresizingFlexibleWidth| 
      UIViewAutoresizingFlexibleHeight;
    iv.contentMode= UIViewContentModeCenter;
    self.view =iv;
    [ivrelease];
}
- (UIImage *)splashImage {
    if (splashImage== nil) {
       self.splashImage = [UIImageimageNamed:@"Default.png"];
    }
    returnsplashImage;
}
- (void)hide {
    if(self.showsStatusBarOnDismissal) 
{
       UIApplication *app =[UIApplication sharedApplication];
       [app setStatusBarHidden:NOwithAnimation:UIStatusBarAnimationFade];
    }
    [selfdismissModalViewControllerAnimated:YES];
}
- (void)viewDidAppear:(BOOL)animated {
    [superviewDidAppear:animated];
    SELdidAppearSelector = @selector(splashScreenDidAppear:);
    if([self.delegate respondsToSelector:didAppearSelector]) {
       [self.delegatesplashScreenDidAppear:self];
    }
    [selfperformSelector:@selector(hide) withObject:nil afterDelay:0];
}
- (void)viewWillDisappear:(BOOL)animated {
    [superviewWillDisappear:animated];
    if([self.delegaterespondsToSelector:@selector(splashScreenWillDisappear:)]) {
       [self.delegatesplashScreenWillDisappear:self];
    }
}
- (void)viewDidDisappear:(BOOL)animated {
    [superviewDidDisappear:animated];
    if([self.delegaterespondsToSelector:@selector(splashScreenDidDisappear:)]) {
       [self.delegatesplashScreenDidDisappear:self];
    }
}
@end




//AppDelagate.h
#import "PRPSplashScreen.h"
@interface AppDelegate_iPhone : NSObject<UIApplicationDelegate,PRPSplashScreenDelegate> {}
@property (nonatomic, retain) IBOutlet UIWindow*window;
@property (nonatomic, retain) IBOutletUINavigationController *navController;
@property (nonatomic, retain) IBOutletPRPSplashScreen *splashScreen;


@end


//AppDelagate.m
#import "AppDelegate_iPhone.h"
#import "PRPSplashScreen.h"
@implementation AppDelegate_iPhone
@synthesize window;
@synthesize navController;
@synthesize splashScreen;


#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication*)application 
      didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self.windowaddSubview:self.navController.view];
   self.splashScreen.showsStatusBarOnDismissal = YES;
   self.splashScreen.modalTransitionStyle =UIModalTransitionStyleFlipHorizontal;
   [self.navController presentModalViewController:splashScreenanimated:NO];
    [self.windowmakeKeyAndVisible];
    return YES;
}
- (void)splashScreenDidAppear:(PRPSplashScreen*)splashScreen {
   NSLog(@"splashScreenDidAppear!");
}
- (void)splashScreenWillDisappear:(PRPSplashScreen*)splashScreen {
   NSLog(@"splashScreenWillDisappear!");
}
- (void)splashScreenDidDisappear:(PRPSplashScreen*)splashScreen {
   self.splashScreen = nil;
}
- (void)dealloc {
    [windowrelease], window = nil;
    [navControllerrelease], navController = nil;
    [splashScreenrelease], splashScreen = nil;
    [superdealloc];
}

posted @ 2015-12-28 14:28  Bo-tree  阅读(96)  评论(0)    收藏  举报