아이폰 개발의 기본 입문 지식

4564 단어
대전제: Xcode -> 클릭 두 번째-> iOS-> Applaction-> Single View Application 다음 응용 프로그램 만들기
1. main.안에
  1、main  ,       

  2、UIApplicationMain        

      1)        UIApplication  ,         ,  UIApplication           

      2)              

      3)                  

  3、        main.m    

2. 프로그램의 생명 주기
#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

#pragma mark           

//1. Applaction       ,          

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.


NSLog(@"         window=%@",self.window);

#pragma mark        UIwindow  
//1).    window  

//UIWindow *customWindow = [[UIWindow alloc]init];

//2).   UIScreen  
UIScreen *screen = [UIScreen mainScreen];

//4). window         

CGRect rect = [screen bounds]; //                  

UIWindow *customWindow = [[UIWindow alloc]initWithFrame:rect];

//5).         

customWindow.backgroundColor = [UIColor blueColor];

//6). window        ,window             

customWindow.rootViewController = [[UIViewController alloc]init];

//7). customwindow   self.window

self.window = customWindow;

//8).    window   window,      

[customWindow makeKeyAndVisible];

#pragma mark           

//          

// 1  
UIView *view = [[UIView alloc]init];
view.frame = CGRectMake(140, 50, 40, 380);
view.backgroundColor = [UIColor yellowColor];
[self.window addSubview:view];

// 1  
UIView *view1 = [[UIView alloc]init];
view1.frame = CGRectMake(50, 50, 220, 40);
view1.backgroundColor = [UIColor greenColor];
[self.window addSubview:view1];

// 2  
UIView *view2 = [[UIView alloc]init];
view2.frame = CGRectMake(50, 220, 220, 40);
view2.backgroundColor = [UIColor redColor];
[self.window addSubview:view2];

// 3  
UIView *view3 = [[UIView alloc]init];
view3.frame = CGRectMake(40, 390, 240, 40);
view3.backgroundColor = [UIColor purpleColor];
[self.window addSubview:view3];




NSLog(@"    ");
return YES;
}

//3.                ,      、   。

 - (void)applicationWillResignActive:(UIApplication *)application {
    NSLog(@"        ");

}

//4.        ,         ,           ,            

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

NSLog(@"      ");
}

//5.      
  - (void)applicationWillEnterForeground:(UIApplication *)application {

  NSLog(@"      ");
}

//2.             
- (void)applicationDidBecomeActive:(UIApplication *)application {

NSLog(@"        ");
 }
//6.           ,                    
- (void)applicationWillTerminate:(UIApplication *)application {

NSLog(@"    ");
}

@end

3. UIWindow
1、 iOS ,                    ,              ,                    ,            ,  :  、  、    

2、            UIWindow keyWindow,          window

3、iOS       ,       UIWindow

4、  iOS            ,       UIWindow,      UIWindow,      UI  

5、    
    
    1)   UIWindow  keyWindow(   )

      - (void)makeKeyWindow;

    2)        

      - (void)makeKeyAndVisible; 

6、  

         window     

4. 프로그램의 완전한 시작 과정
1、main  

2、UIApplicationMain
   
   1)  UIApplication  
   2)  UIApplication delegate  

3、delegate      (  )    


  1)         ,        application:didFinishLaunchingWithOptions:  

  2) application:didFinishLaunchingWithOptions:   UIWindow

  3)     UIWindow rootViewController
  4)    

5. 핸드폰 화면의 몇 가지 개념
1、UIScreen
    iOS        ,

[UIScreen mainScreen] bounds]         

2. 화면 크기

3. 픽셀

4. 화면 해상도
                

5. 화면 크기
                   (pt) reader    (px) 

  3GS       3.5      320*480   @1x     320*480

  4/4S      3.5      320*480   @2x     640*960

  5/5S/5C   4.0      320*568   @2x     750*134

  6         4.7      375*667   @2x     750*1334

  6P        5.5      414*736   @3x     1242*2208


  pt:           

6. iOS 좌표계
1、iPhone              

2、   view frame                    

3、         

   //       
   CGPoint point = CGPointMake(x,y) 

   //       
   CGSize size = CGSizeMake(width,height)

   //          
   CGRect rect = CGRectMake(x,y,width,height);

4、frame/Bounds/center

   frame:           
   Bounds:       ,     (0,0)
   center:            

좋은 웹페이지 즐겨찾기