//맥부기 카페에서 문씨님 강좌의 에기스만 요약함.
// UIButton
UIButton *button = [self CreateButton:@"시간표" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(20.0, 310.0, 135.0, 50.0) target:self action:@selector(cmdOpenTimeTable)];
title: 버튼에 들어갈 제목
type: 버튼 종류
UIButtonTypeCustom = 0, // no button type
UIButtonTypeRoundedRect, // rounded rect, flat white button, like in address card
UIButtonTypeDetailDisclosure,
UIButtonTypeInfoLight,
UIButtonTypeInfoDark,
UIButtonTypeContactAdd,
// UITable
UITable *myTable = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0) style:UITableViewStylePlain];
myTable.delegate = self;
myTable.dataSource = self;
[self.view addSubview:myTable];
[myTable release];
[Header]
@interface TimeTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView *myTable;
// UILabel
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 30.0)];
label.text = @"test";
[label setBackgroundColor:[UIColor clearColor]];
label.textColor = [UIColor whiteColor];
label.textAlignment = UITextAlignmentCenter;
[self.view addSubview:label];
// UINavigationController
AppDelegate
- navigationController
+ 뷰 컨트롤러
+ 뷰 컨트롤러
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:처음 시작할 뷰컨트롤러];
navigationController.delegate = self;
[navigationController setNavigationBarHidden:YES]; //네비게이션 바를 숨김
[window addSubview:navigationController.view];
뷰컨트롤러 *VC = [[뷰컨트롤러 alloc] init];
[self.navigationController pushViewController:VC animated:YES];
[VC release];
컨트롤러를 만들어서 넣을 때 그 컨트롤로의 헤더를 참조
// UISegmentedControl
UISegmentedControl *buttonBarSegmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"옵션1", @"옵션2", nil]];
buttonBarSegmentedControl.frame = CGRectMake(0.0, 480.0 - 40.0, 320.0, 40.0); //크기 및 위치 설정
[buttonBarSegmentedControl addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged]; //이벤트 설정 옵션선택이 바뀔때 호출
buttonBarSegmentedControl.selectedSegmentIndex = 0.0; //시작 선택된버튼
buttonBarSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
//buttonBarSegmentedControl.tintColor = [UIColor darkGrayColor]; //버튼 색
//buttonBarSegmentedControl.backgroundColor = [UIColor clearColor]; 배경색
[self.view addSubview:buttonBarSegmentedControl]; //뷰에 넣기
[buttonBarSegmentedControl release];
선택이 호출 될 경우 구별법
- (void)onChange:(id)sender {
UISegmentedControl *i = sender; //sender로 포인터 값이 들어오므로
switch (i.selectedSegmentIndex ) {
case 0:
//.....
break;
default:
break;
}
}
'++++++++++ 관리 안 함 ++++++++++ > iOS' 카테고리의 다른 글
Admob (0) | 2012.05.11 |
---|---|
문자열을 다루는 Method를 정리 (0) | 2012.01.15 |
아이폰 앱 76개 소스코드, 강좌, 개발 팁 링크모음 (0) | 2011.12.22 |
비튼 이벤트에 관련된 제어... (0) | 2011.12.21 |
개발자 등록 완료 (1) | 2011.12.02 |