2011-10-13 3 views
12

Facebook의 앱과 같은 로그인 화면을 만들고 싶습니다. 내가 복제하고 싶은 부분은 테이블 그룹처럼 쌓여있는 두 개의 텍스트 필드입니다. 나는 그들이 어떻게했는지 알 수 없다.iOS : 로그인 화면의 표 스타일 텍스트 필드?

누가 트릭을 알고 있습니까?

stackoverflow를 처음 사용하기 때문에 사진을 게시 할 수 없습니다. 마치 하나의 둥근 타원처럼 보이지만 내부에 2 개의 텍스트 필드가있는 것입니다. 하나는 사용자 이름 용이고 다른 하나는 암호 용입니다.

+0

이미 작성된이 컨트롤에 관심이있을 수 있습니다. http://cocoacontrols.com/platforms/ios/controls/ddalertprompt – Luke

+0

이미지를 업로드하려는 경우 연결된 컨트롤에 표시된 아래 컨트롤을 사용할 수 있습니다 이미지 : http://img31.imageshack.us/img31/566/screenshot20111015at317.png – User97693321

답변

11

아래 코드를 사용할 수 있습니다.

// .H 파일에

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
     return 2; 
    } 
    - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

     UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"]; 
     if(cell == nil) 
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease]; 

     if (indexPath.row == 0) { 
      loginId = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)]; 
      loginId .placeholder = @"loginid"; 
      loginId .autocorrectionType = UITextAutocorrectionTypeNo; 
      [loginId setClearButtonMode:UITextFieldViewModeWhileEditing]; 
      cell.accessoryView = loginId ; 
     } 
     if (indexPath.row == 1) { 
      password = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)]; 
      password.placeholder = @"Password"; 
      password.secureTextEntry = YES; 
      password.autocorrectionType = UITextAutocorrectionTypeNo; 
      [password setClearButtonMode:UITextFieldViewModeWhileEditing]; 
      cell.accessoryView = password; 
     } 
     loginId.delegate = self; 
     password.delegate = self; 


     [tableView1 addSubview:loginId]; 
     [tableView1 addSubview:password]; 
     [loginId release]; 
     [password release]; 

     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     return cell; 
    } 
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 

     return 1; 
    } 
+0

댓글에 댓글 옵션을 사용하십시오. – JustSid

+0

위대한 대답, 한 가지 질문. 그룹화 된 두 셀의 위치를 ​​이동하는 방법이 있습니까? 아니면 화면 상단에 있어야합니까? – BlueMeanie

3

둥근 모서리가있는 UIVIew를 배경으로 사용하고 두 텍스트 필드를 하위보기로 추가하십시오.

-2

UITableView을 받고 UITextFieldaccessoryType으로 추가 할 수 있습니다.

4

아! 나는 대답을 얻었다. 그것은 단지 예술입니다. 무한 UITextFields와 함께 2 셀 테이블 뷰처럼 보이는 UIImage입니다. 내가 예술이라고 추측하지 않는 이유는 무엇일까요?

9

여기에서 코드 가져

UITextField *loginId; 
UITextField *password ; 

//하는 .m 파일에

: 코드를 다운로드하는 경우 https://github.com/c99koder/lastfm-iphone

를하고 조사 FirstRunView.xib에서 원하는대로 동일한 구현을 볼 수 있습니다.

+5

그냥 lastfm 코드를 살펴 보는 사람을 위해 머리를 들고, 이미지를 사용하여 그룹화 된 TableView 효과를 얻습니다. –