'UITextField'에 해당되는 글 1건

  1. 2012.04.20 [xcode] 기본 컨트롤.

[xcode] 기본 컨트롤.

iPhone 2012. 4. 20. 11:53



//// 버튼


    UIButton *okBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    okBtn.frame = CGRectMake(61, 210, 200, 30);

    [okBtn setTitle:@"OK Button" forState:UIControlStateNormal];


//// 라벨


    UILabel *label = [[UILabel allocinitWithFrame:CGRectMake(1001010024)];

    label.backgroundColor = [UIColor clearColor];

    label.textColor = [UIColor whiteColor];

    label.text = @"label1";

//// 텍스트 필드


    UITextField *tf = [[UITextField allocinitWithFrame:CGRectMake(101010024)]; 

    tf.backgroundColor = [UIColor blueColor];

    tf.borderStyle = UITextBorderStyleLine;

// CGRectMake의 1, 2인수는 시작점. 3,4인수는 프레임의 크기.


    UITextField *tf1 = [[UITextField allocinitWithFrame:CGRectMake(104010024)];    

    tf1.backgroundColor = [UIColor whiteColor];

    tf1.borderStyle = UITextBorderStyleLine;


    [self.view addSubview:tf];

    [self.view addSubview:tf1];


//// 루프로 컨트롤 생성, 접근


    UITextField *textField;

    for (int i=0; i < 5; i++){

        

        textField =

        [[UITextField allocinitWithFrame:CGRectMake(1010 + 30 * i, 10024)];

        textField.borderStyle = UITextBorderStyleLine;

        textField.tag = i;

  //생성된 컨트롤러의 접근을 위해 태그 붙임.

        [self.view addSubview:textField];


    }

    

    UITextField *tf = [self.view viewWithTag:3];

    tf.text = @"tag access";

    [tf addTarget:self action:@selector(endEditing:) forControlEvents:UIControlEventEditingDidEnd];



- (void) endEditing:(id)sender{

//or (IBAction)

//Code만으로 할때는 void리턴타입이어도 됨. 파라메터에 주의.

NSLog(@"endEditing...");

}










Posted by tenn
,