您的位置:首页 > 移动开发

IOS AppDelegate介绍

2014-12-25 10:10 274 查看
@interface ownmoneyAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

window为当前应用显示窗口。

#import "AppDelegate.h"
#import "HomeViewController.h"
#import "BandViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//覆盖后,应用程序启动定制即决定App初始化显示内容
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//使用Storyboard初始化根界面
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// self.window.rootViewController = [storyBoard instantiateInitialViewController];
// HomeViewController *home = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
HomeViewController *home = [storyBoard instantiateViewControllerWithIdentifier:@"HomeViewController"];
BandViewController *nav = [[BandViewController alloc] initWithRootViewController:home];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. //当应用程序即将从活动转移到非活动状态时发送。这可能会发生某些类型的临时中断(例如呼入电话呼叫或SMS消息),或者当用户退出该应用程序和它开始过渡到背景状态。
    //使用这个方法来暂停正在进行的工作,关闭计时器,并踩下油门的OpenGL ES的帧速率。游戏应该使用这种方法来暂停游戏。
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. //使用这个方法来释放共享资源,保存用户数据,无效计时器,并储存足够的应用程序状态信息到你的应用程序恢复到其当前状态的情况下,它后来终止。
    //如果您的应用程序支持后台运行,这种方法被称为代替applicationWillTerminate:当用户退出。
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. //调用作为从背景到非活动状态的转换的一部分;在这里您可以撤消许多就进入后台的变化。
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. //重新启动被暂停的(或尚未开始),而应用程序是不活动的任何任务。如果该应用程序是以前的背景,任选刷新用户界面。
}

- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. //当应用程序即将终止调用。如果适当保存数据。另请参见applicationDidEnterBackground:.
}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  IOS AppDelegate