Research Topics/iPhone SDK2009. 2. 21. 14:16
  


1. Navigation-Based Application 으로 프로젝트 생성
   - AppDelegate 와 RootViewController 가 기본적으로 생성됨
   - 이때 RootViewController 는 UITableViewController 를 상속받고, tableView 라는 UITableView 를 담고 있음
      그리고, AppDelegate 의 UINavigationController 에서 보여지는 첫 화면이 됨
   - AppDelegate 는 UINavigationController *navigationController 를 담고 있음 
 
2. RootViewController의 tableView 를 위한 모델(데이터) 생성
   - AppDelegate의 applicationDidFinishLaunching와 같은 초기화 부분에서 NSArray 등의 데이터 생성
   - RootViewController 는 UITableViewController를 상속받으므로, tableView와 관련된 메소드가 정의되어 있음
      이 메소드들을 수정하여 데이터를 채워줄 수 있도록 함
      (numberOfSectionsInTableView, numberOfRowsInSection, cellForRowAtIndexPath)

3. 메뉴 선택시 로드될 UIViewController 추가 
   - Add - New File - UIViewController subclass 또는 기타 목적에 맞는 클래스 선택
   - xib 파일도 RootViewController.xib 등을 열어 새이름으로 저장, 새클래스 이름 지정

4. 하위 계층의 새로운 UI 로딩(push) 구현
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 부분에서
       하위 계층의 새로운 UIViewController (또는 다른 UIView 화면)를 로딩하도록 구현 (pushViewController 사용)

       예)
        AboutViewController *aboutViewController = [[AboutViewController alloc]
        initWithNibName:@"AboutViewController" bundle:nil];
        [self.navigationController pushViewController:aboutViewController animated:YES];
        [aboutViewController release];

    - 이때 self.navigationController 는 UINavigationController 에 담긴 View controller 라면 접근 가능하도록 되어있음
     
5. 하위계층에서 복귀(pop)는 특별히 구현하지 않아도 됨
    - UINavigationController 의 Back 버튼 처리가 자동으로 됨
    - 다른 버튼 등을 사용한 수동 구현시는 [self.navigationController popViewControllerAnimated:YES]; 사용



Posted by 알 수 없는 사용자