2011. 12. 5. 10:51
[Xcode 4.2] 스토리보드를 이용한 객체 생성
2011. 12. 5. 10:51 in 아이폰
기존의 xib을 이용한 객체생성은 아래와 같았다.
RootViewController *rootViewController = [[RootViewController alloc] initWithNibName:@"NIB명" bundle:nil];
하지만 4.2부터 스토리보드를 이용할 경우 xib파일이 없기 때문에 위의 방법은 쓸 수 없다.
스토리보드를 이용한 방법은 아래와 같다.
RootViewController *rootViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"identifier"]];
identifier자리에는 스토리보드에서 설정한 view controller의 identifier를 적어주면 된다.
또한 뷰 전환은 아래와 같이 하면 된다.
[모달]
[self presentModalViewController:rootViewController animated:YES];
[푸쉬]
[self.navigationController pushViewController:rootViewController animated:YES];
RootViewController *rootViewController = [[RootViewController alloc] initWithNibName:@"NIB명" bundle:nil];
하지만 4.2부터 스토리보드를 이용할 경우 xib파일이 없기 때문에 위의 방법은 쓸 수 없다.
스토리보드를 이용한 방법은 아래와 같다.
RootViewController *rootViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"identifier"]];
identifier자리에는 스토리보드에서 설정한 view controller의 identifier를 적어주면 된다.
또한 뷰 전환은 아래와 같이 하면 된다.
[모달]
[self presentModalViewController:rootViewController animated:YES];
[푸쉬]
[self.navigationController pushViewController:rootViewController animated:YES];
'아이폰' 카테고리의 다른 글
[Objective C] 숫자를 표현하는 세가지 방법 (0) | 2011.12.06 |
---|---|
[Xcode 4.2] 소스 별로 ARC를 해제하기 (0) | 2011.12.05 |
[Xcode 4.2] 스토리보드에서 뷰전환시 데이터 처리 (0) | 2011.12.01 |
[Xcode 4.2] 느린 xcode 4 최적화 하기 (0) | 2011.11.30 |
[Xcode 4.2] navigation-based application 프로젝트 생성방법 (0) | 2011.11.30 |