|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
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里了 |
|