ios程序不同状态下,调用的代理方法
2016-04-15 10:27
381 查看
- (void)dealloc
{
[window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.rootViewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
[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.
NSLog(@"applicationWillResignActive");
}
- (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.
NSLog(@"applicationDidEnterBackground");
}
- (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.
NSLog(@"applicationWillEnterForeground");
}
- (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.
NSLog(@"applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
NSLog(@"applicationWillTerminate");
}
进入程序后先打印出 applicationDidBecomeActive 即先调用- (void)applicationDidBecomeActive:(UIApplication *)application
再让程序进入后台,先调用的是
- (void)applicationWillResignActive:(UIApplication *)application
再调用
- (void)applicationDidEnterBackground:(UIApplication *)application
同理,再点击程序图片再次进入程序先调用的是
- (void)applicationWillEnterForeground:(UIApplication *)application
再接着就调用
- (void)applicationDidBecomeActive:(UIApplication *)application
这样就对整个程序的运行状态初步了解了,你的APP在程序进入后台后要做什么返回后还得做什么就在相应的方法中码好你的代码就OK啦。
{
[window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.rootViewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
[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.
NSLog(@"applicationWillResignActive");
}
- (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.
NSLog(@"applicationDidEnterBackground");
}
- (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.
NSLog(@"applicationWillEnterForeground");
}
- (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.
NSLog(@"applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
NSLog(@"applicationWillTerminate");
}
进入程序后先打印出 applicationDidBecomeActive 即先调用- (void)applicationDidBecomeActive:(UIApplication *)application
再让程序进入后台,先调用的是
- (void)applicationWillResignActive:(UIApplication *)application
再调用
- (void)applicationDidEnterBackground:(UIApplication *)application
同理,再点击程序图片再次进入程序先调用的是
- (void)applicationWillEnterForeground:(UIApplication *)application
再接着就调用
- (void)applicationDidBecomeActive:(UIApplication *)application
这样就对整个程序的运行状态初步了解了,你的APP在程序进入后台后要做什么返回后还得做什么就在相应的方法中码好你的代码就OK啦。
相关文章推荐
- ios基础笔试题-集锦二
- iOS 真机调试
- iOS基础笔试题 - 集锦一
- iOS 获取系统音量
- iOS开发bug调试技巧之Debug View Hierarchy
- ios判断邮箱,手机号码,车牌号是否合法(正则表达)
- iOS 打包ipa最简单粗暴的方式
- iOS被打回
- CocoaPods安装使用及配置私有库
- iOS _MJRefresh 导入最新Xcode 报错 解决方法
- 最新苹果开发者账号注册流程详解
- cocodata有一个版本迭代
- iOStextfield 限制输入字符长度和过滤表情符号
- iOS线程其一NSThread
- DBGridEh-在指示列显示复选框:gioShowRowselCheckboxesEh、dgMultiSelect
- IOS 开发中判断字符串是否为空字符的方法
- IOS应用程序多语言本地化解决方案
- iOS学习笔记27-摄像头
- iOS开发 ☞ YY_Model
- iOS学习笔记27-摄像头