iphone开发简介(16.5.19)

来源:互联网 发布:kmeans聚类算法matlab 编辑:程序博客网 时间:2024/06/07 19:39

 注:屏幕分辨率是物理屏幕的两倍


启动背景图:

2x表示iphone4系列的启动背景;

Retina 4表示iphone5系列的启动背景;

Retina HD 4.7表示iphone6的启动背景;

Retina HD 5.5表示iphone6+的启动背景;


启动背景图必须是png格式的图片且后缀@2x或@3x形式命名,

表示支持高清屏或iphone6/iphone6 plus。

如果要支持iphone5/iphone5c/iphone5s则要以Default-568h@2x.png形式命名。


APP生命周期

应用程序委托是实现APP生命周期的关键点,委托负责初始化UIWindow窗口系统,初始化根视图控制器。

int main(int argc,char * argv[]) {

    NSLog(@"1.程序从main函数入口开始");

    @autoreleasepool {

        returnUIApplicationMain(argc, argv, nil,NSStringFromClass([AppDelegateclass]));

    }

}

重要委托方法:

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    NSLog(@"2.程序将要启动");

    return YES;

}


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

    // Override point for customization after application launch.

    NSLog(@"3.程序启动完成");

    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(@"程序将要失去激活状态");

    

    //shift+command+h

}


- (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(@"程序已经进入后台");

}


- (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(@"程序将要进入前台");

}


- (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(@"4.程序已经激活");

}


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

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

}


- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application

{

    NSLog(@"手机内存不足了,程序收到内存警告了!");

}


IOS设计模式-MVC
Model View Controller(MVC)是一种最早的也是最成功的可重用设计模式。我们可以理解为:数据模型、视图、控制器。
Model:为应用程序提供独立的,不依赖于View和Controller的数据模型。
View:用界面的形式向用户呈现数据,同时也允许用户对数据进行操作。
Controller:用于消除model和view之间的耦合性。用户和view交互时,view会通知controller在view中有数据发生了更改,而controller则会将这个数反应到model中,反之,model有数据改变时,controller将改变的数据反应到view中,view推出界面刷新显示给用户。
如下图:






0 0
原创粉丝点击