iOS 开发学习之 User Interface(1)APP 生命周期

一,APP 生命周期

OC的学习在Fundation框架下,UI阶段的学习在触摸层(Cocoa Touch Layer)下的UIKit框架下(Cocoa:是OS X 和iOS 操作系统的程序运行环境)。

 

应用程序入口 ***

            main函数:

            int UIApplicationMain(int argc,char *argv[], NSString *principalClassName,NSString *delegateClassName);

            // argc, argv 由main函数传递给UIApplicationMain.  参数包含应用程序何时,何地从系统启动。

            // principalClassName 标识应用程序的类的名称,必须是UIApplication 类或者其子类的类名称。若传递了nil 则默认为UIApplication的类名称。(整个应用程序的老大)

           //  delegateClassName 标识应用程序类(UIApplication)的代理类的名称。(负责系统与应用程序间的高层次互动,例如老大的生命周期)

           UIApplicationMain函数通过接收到的第三,第四参数,实例化一个应用程序对象和应用程序代理对象。除此之外,1.建立了应用程序的事件循环,并且开始处理事件;2. 从info.plist加载指定的主视图文件。

 

—————————————————————————————— 

//  应用程序生命周期

//  AppDelegate.m 中

//  1:

//application:didFinishLaunchingWithOptions:  应用程序准备工作,完成加载,准备要运行了

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    return YES;

}

 

//  2:

//程序变为激活状态

//重启那些,当应用程序是未被激活状态时,被暂停的任务(或者尚未被启动的任务);如果应用程序之前是在后台,那么选择性的刷新用户界面

- (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.

}

 

//  3

//应用程序将要释放激活状态(还未激活),开始转为非激活状态

// 该方法是应用程序从激活状态转向非激活状态的时候发生,一般发生在几种特定的临时中断(来电话了,或者短信),或者用户退出应用程序并且转向后台的时候。(激活、非激活、后台-三个状态)

    // 使用此方法,去暂停正在运行的任务,禁用定时器,降低3D的图形帧速率,如果是游戏那就暂停游戏

- (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.

}

 

//  4

// 应用程序进入后台

// 使用此方法释放共享的资源,保存用户数据,使定时器无效化,并且保存足够的应用程序状态信息,为了恢复应用程序到当前的状态,以防后续再回到应用中

// 如果应用程序支持后台执行,此方法会代替 applicatioWillTerminate: 程序完全终止,当用户退出应用程序的时候

- (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.

}

 

//  5

// 应用程序将要进入前台

// 发生在从那个后台到非激活状态转换的过程中

    // 可以恢复之前在进入后台时所做的修改

- (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.

 }

 

// 6

// 应用程序将要终止(主要判断程序是否支持后台执行)

- (void)applicationWillTerminate:(UIApplication *)application {

    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}

  ——————————————————————————————

App Name & App Logo

      a. App Name 显示在手机屏幕上的名字(注意与工程名字的区分)

         在Info.plist中添加 Bundle display name ,值可任意设置,中英文都可以。一般控制在中文5个字以内。多了的话,在屏幕显示的时候就有省略号了。

      b. App Logo 

         App 因为可运行在不同版本的设备上,所以logo的尺寸有很多种,理想的情况下,最好给每种设备都准备好对应尺寸的logo。(上架的时候要多准备几种)。

         注意:Xcode中尺寸单位是pt(点),而图片的尺寸单位是px(像素)。他们的关系:一个点上可以有多个像素,通俗讲:一个点上可以滴几滴颜料,越多,图越清晰。

         在Assets.xcassets->AppIcon 中 1x,2x,3x 表示 1个点上有1/2/3 个像素,例如 60pt 下2x, 表示要设置一个120像素的图片.

——————————————————————————————

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值