-(IBAction)clickedAlert1:(id)sender
{
    NSLog(@"clickedAlert1:");
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"로그인" 
                                                    message:@"\n\n\n" 
                                                   delegate:self 
                                          cancelButtonTitle:nil 
                                          otherButtonTitles:@"취소", @"확인", nil];

    // 아이디
    UITextField *fieldID = [[UITextField alloc] initWithFrame:CGRectMake(17.0, 50.0, 250.0, 30.0)];
    fieldID.backgroundColor = [UIColor whiteColor];
    fieldID.borderStyle =  UITextBorderStyleNone;
    fieldID.font = [UIFont fontWithName:@"Helvetica" size:20];
    fieldID.placeholder = @"아이디";
    fieldID.tag = 1000;
    [fieldID becomeFirstResponder]; // 첫번째에 키보드 포커스를 가게 한다.

    [alert addSubview: fieldID];
    [fieldID release];
    
    // 비밀번호
    UITextField *fieldPwd = [[UITextField alloc] initWithFrame:CGRectMake(17.0, 81.0, 250.0, 30.0)];
    fieldPwd.backgroundColor = [UIColor whiteColor];
    fieldPwd.borderStyle =  UITextBorderStyleNone;
    fieldPwd.font = [UIFont fontWithName:@"Helvetica" size:20];
    fieldPwd.placeholder = @"비밀번호";
    fieldPwd.secureTextEntry = TRUE;
    fieldPwd.tag = 1001;
    
    [alert addSubview: fieldPwd];
    [fieldPwd release];    
    
    [alert show];
    [alert release];
}


위와 같이 특정 이벤트에서 설정해주고
UIAlertViewDelegate 에서 tag값으로 컨트롤들을 가져와서 값을 읽어오면 된다. 
또한 자신의 앱에 맞게 Custom AlertView를 만들고 싶으면
UIAlertView를 상속 받고 drawRect 오버라이딩 해서 직접 그려줘야 한다. 
posted by 뚱2