1. Project 생성
1) Create a new Xcode Project -> Window based Application -> "SendData"
2. Navigation Controller 추가/구현
1) Navigation Controller 추가 (Drag & Drop)
2) Header /Source 파일에 변수 및 addSubView 함수 추가
3) 변수 연결
3. 클래수 추가
1) 세개의 뷰를 추가
a. Class 폴더 마우스 우측 클릭, Add -> New File -> "UIView Controller subClass" with Xib for user interface
"FirstView", "SecondView" 추가
b. "Text Field" "Round Button"을 first view에 Drag & Drop 추가
c. header 관련 변수 및 함수 추가
- 변수 연결 : File's Owner는 먼저 선택하고 마우스 오른쪽 클릭 후 Text Field에 Drag & Drop 후 "textField" 선택
- 함수 연결 : Round Button을 먼저 선택하고 File's Owner에 Drag & Drop 후 "sendSecondView" 선택
e. Navigation Cotroller에 FirstView 적용
- MianWindow.Xib에서 Navigation Controller를 펼쳐, View Controller를 선택
- View Controller의 Attributes창(Cmmnd+1)에서 NIB NAME에서 FirstView를 선택, Identity에서도 Class 항목을 FirstView Class를 선택하여 실행
f. 함수 연결 및 추가
a. Class 폴더 마우스 우측 클릭, Add -> New File -> "UIView Controller subClass" with Xib for user interface
"FirstView", "SecondView" 추가
b. "Text Field" "Round Button"을 first view에 Drag & Drop 추가
c. header 관련 변수 및 함수 추가
d. 변수와 함수를 연결 (FirstView.Xib )@interface FirstView : UIViewController {
IBOutlet UITextField *textData;
}
-(IBAction) sendSecondView;
@end
- 변수 연결 : File's Owner는 먼저 선택하고 마우스 오른쪽 클릭 후 Text Field에 Drag & Drop 후 "textField" 선택
- 함수 연결 : Round Button을 먼저 선택하고 File's Owner에 Drag & Drop 후 "sendSecondView" 선택
e. Navigation Cotroller에 FirstView 적용
- MianWindow.Xib에서 Navigation Controller를 펼쳐, View Controller를 선택
- View Controller의 Attributes창(Cmmnd+1)에서 NIB NAME에서 FirstView를 선택, Identity에서도 Class 항목을 FirstView Class를 선택하여 실행
f. 함수 연결 및 추가
#import "FirstView.h"
#import "SecondView.h"
@implementation FirstView
...
-(IBAction) sendSecondView
{
UINavigationController *sNav = self.navigationController;
SecondView *sView = [[SecondView alloc] initWithNibName:@"SecondView" bundle:nil];
[sNav pushViewController:sView animated:YES];
[sView release];
}
...
- (void)dealloc {
[textField release];
[super dealloc];
}
4. XIB 연동 및 값전달
1) SecondView 구현
a. NSString *recevieData 변수 추가 및 @property 및 @synthesize 구현
b. View에 Label Drag & Drop하고 변수추가(IBOutlet UILabel *lblText) 및 연결
@interface SecondView : UIViewController {
NSString *receiveData;
IBOutlet UILabel *lblText;
2) FirstView의 sendSecondView에 값전달 기능 구현@implementation SecondView
@synthesize receiveData;
...
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
lblText.text = receiveData;
[super viewDidLoad];
}
...
- (void)dealloc {
[lblText release];
[super dealloc];
}
-(IBAction) sendSecondView
{
UINavigationController *sNav = self.navigationController;
SecondView *sView = [[SecondView alloc] initWithNibName:@"SecondView" bundle:nil];
sView.receiveData = textData.text;
[sNav pushViewController:sView animated:YES];
[sView release];
}
'아이폰개발 > AppsNext강좌정리' 카테고리의 다른 글
[AppsNext] iPhone SDK 기본강좌_10강 UIAlertView, UIActionSheet 사용해보기 (1) | 2010.06.25 |
---|---|
[AppsNext] iPhone SDK 기본강좌_9강 Picker 컨트롤 사용해보기 (0) | 2010.06.24 |
[AppsNext] iPhone SDK 기본강좌_7강 탭바컨트롤러(테이블+네비게이션+탭바) (0) | 2010.06.17 |
[AppsNext] iPhone SDK 기본강좌_6강 다중 Xib 사용하기 (0) | 2010.06.15 |
[AppsNext] iPhone SDK 기본강좌_5강 Navigation Controller (0) | 2010.06.13 |