++++++++++ 관리 안 함 ++++++++++/iOS

문씨님 강좌 IB없이 코딩하기 정리

알렉스윤 2012. 6. 12. 20:43

//맥부기 카페에서 문씨님 강좌의 에기스만 요약함.

 

 

// 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];

[label release];

 

 

// 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;

        }

}