仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1906|回复: 19
打印 上一主题 下一主题

[学习教程] IOS编程:iOS开辟――性命周期仓酷云

[复制链接]
爱飞 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-18 11:43:09 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
很简单OBJCAVFoundation---播放视频相关的库最近正在学习这些算是学iOS开发的一些方法为了处置好使用程序的挂起、停息等情形下的数据保留,或对应增加所需处置,我们必需懂得ios性命周期。
可是不要往背往记,做个实行就好。
[cpp]

  • -(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions
  • {
  • //Overridepointforcustomizationafterapplicationlaunch.
  • NSLog(@"程序入手下手");
  • returnYES;
  • }

  • -(void)applicationWillResignActive:(UIApplication*)application
  • {
  • //Sentwhentheapplicationisabouttomovefromactivetoinactivestate.Thiscanoccurforcertaintypesoftemporaryinterruptions(suchasanincomingphonecallorSMSmessage)orwhentheuserquitstheapplicationanditbeginsthetransitiontothebackgroundstate.
  • //Usethismethodtopauseongoingtasks,disabletimers,andthrottledownOpenGLESframerates.Gamesshouldusethismethodtopausethegame.
  • NSLog(@"程序停息");
  • }

  • -(void)applicationDidEnterBackground:(UIApplication*)application
  • {
  • //Usethismethodtoreleasesharedresources,saveuserdata,invalidatetimers,andstoreenoughapplicationstateinformationtorestoreyourapplicationtoitscurrentstateincaseitisterminatedlater.
  • //Ifyourapplicationsupportsbackgroundexecution,thismethodiscalledinsteadofapplicationWillTerminate:whentheuserquits.
  • NSLog(@"程序进进背景");
  • }

  • -(void)applicationWillEnterForeground:(UIApplication*)application
  • {
  • //Calledaspartofthetransitionfromthebackgroundtotheinactivestate;hereyoucanundomanyofthechangesmadeonenteringthebackground.
  • NSLog(@"程序进进前台");
  • }

  • -(void)applicationDidBecomeActive:(UIApplication*)application
  • {
  • //Restartanytasksthatwerepaused(ornotyetstarted)whiletheapplicationwasinactive.Iftheapplicationwaspreviouslyinthebackground,optionallyrefreshtheuserinterface.
  • NSLog(@"程序再次激活");
  • }

  • -(void)applicationWillTerminate:(UIApplication*)application
  • {
  • //Calledwhentheapplicationisabouttoterminate.Savedataifappropriate.SeealsoapplicationDidEnterBackground:.
  • NSLog(@"程序不测停止");
  • }

-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{//Overridepointforcustomizationafterapplicationlaunch.NSLog(@"程序入手下手");returnYES;}-(void)applicationWillResignActive:(UIApplication*)application{//Sentwhentheapplicationisabouttomovefromactivetoinactivestate.Thiscanoccurforcertaintypesoftemporaryinterruptions(suchasanincomingphonecallorSMSmessage)orwhentheuserquitstheapplicationanditbeginsthetransitiontothebackgroundstate.//Usethismethodtopauseongoingtasks,disabletimers,andthrottledownOpenGLESframerates.Gamesshouldusethismethodtopausethegame.NSLog(@"程序停息");}-(void)applicationDidEnterBackground:(UIApplication*)application{//Usethismethodtoreleasesharedresources,saveuserdata,invalidatetimers,andstoreenoughapplicationstateinformationtorestoreyourapplicationtoitscurrentstateincaseitisterminatedlater.//Ifyourapplicationsupportsbackgroundexecution,thismethodiscalledinsteadofapplicationWillTerminate:whentheuserquits.NSLog(@"程序进进背景");}-(void)applicationWillEnterForeground:(UIApplication*)application{//Calledaspartofthetransitionfromthebackgroundtotheinactivestate;hereyoucanundomanyofthechangesmadeonenteringthebackground.NSLog(@"程序进进前台");}-(void)applicationDidBecomeActive:(UIApplication*)application{//Restartanytasksthatwerepaused(ornotyetstarted)whiletheapplicationwasinactive.Iftheapplicationwaspreviouslyinthebackground,optionallyrefreshtheuserinterface.NSLog(@"程序再次激活");}-(void)applicationWillTerminate:(UIApplication*)application{//Calledwhentheapplicationisabouttoterminate.Savedataifappropriate.SeealsoapplicationDidEnterBackground:.NSLog(@"程序不测停止");}
实行了局:
1.初次启动使用程序:
2012-06-2611:06:39.313WQTest[485:17903]程序入手下手
2012-06-2611:06:39.320WQTest[485:17903]程序再次激活
2.摁HOME键加入:
2012-06-2611:08:08.687WQTest[485:17903]程序停息
2012-06-2611:08:08.690WQTest[485:17903]程序进进背景

3.再次进进程序:
2012-06-2611:09:11.047WQTest[485:17903]程序进进前台
2012-06-2611:09:11.049WQTest[485:17903]程序再次激活

管理所有设备发生的事件比如屏幕旋转屏幕关闭或者一些其他的程序的控制逻辑也应该写在这里他的初始化函数是-(id)initWithNibName:(NSString*)nibNamebundle:(NSBundle*)nibBundle后面那个NibName是InterfaceBuilder里设计的界面现在IB已经集成到XCode里了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-17 03:54

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表