2013-12-08 1 views
0

커스텀 UITableViewCell을 사용하는 UITableView가 있습니다. 내 UITableVewCell에는 내 사용자 지정 UITableViewCell이있는 UITableView를 보유하고있는 주 ViewController에 태그를 추가 한 두 개의 텍스트 필드가 있습니다.커팅 소슬을 스크롤하는 방법 UIKeyboard 위의 UITextFieldCell

그래서 이것은 내부의 코드 내 tableView:cellForRowAIndexPath:

static NSString *CellIdentifier = @"Cell"; 
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[CustomFCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

NSString *widthString = [currentFDictionary objectForKey:@"MM"]; 
     if ((NSNull *) widthString != [NSNull null]) { 
      cell.widthTexField.text = widthString; 
      cell.widthTexField.tag = indexPath.row; 
     } else { 
      cell.widthTexField.text = @" "; 
     } 

NSString *heightString = [currentFDictionary objectForKey:@"NM"]; 
     if ((NSNull *) heightString != [NSNull null]) { 
      cell.heightTextField.text = heightString; 
      cell.heightTextField.tag = indexPath.row; 
     } else { 
      cell.heightTextField.text = @" "; 
     } 


     return cell; 
그때 지금보기에 표시됩니다 UIKeyboard 위에있는 UITableViewCell 스크롤이 .tag를 사용하는 방법을 알고 싶습니다

.

Anyhelp이 크게 감사 할 것입니다. 내가 생각할 수있는

+0

입니다 :

cell.widthTexField.delegate = self; //... cell.heightTextField.delegate = self; 

자,이 방식으로 -textFieldShouldBeginEditing: 위임 방법을 사용 커스텀 셀 xib를 사용한다면'cell = [[CustomFCell alloc] initWithStyle : UITableViewCellStyleDefault reuseIdentifier : CellIdentifier];'작동하지 않는 것 같습니다 ... d 그것이 당신을 위해 일하는 oes? (그러나 이것은 주요 이슈가 아니라 단지 관찰 일뿐입니다.) – staticVoidMan

답변

1

하는 간단한 방법은 -scrollToRowAtIndexPath:atScrollPosition:animated:

UITextField 개체에 대한 대리자를 설정 사용하는 것입니다. 내가 여기 테스트하지 않았기 때문에

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{ 
    NSIndexPath *currentSelectedIndexPath = [self.tableView indexPathForSelectedRow]; 

    [self.tableView scrollToRowAtIndexPath:currentSelectedIndexPath 
        atScrollPosition:UITableViewScrollPositionTop 
          animated:YES]; 
} 
//NOTE: this way we don't really need to work with the textField tag per se 
//(unless you are using it elsewhere as well) 
//Instead, we work with the entire cell and scroll it to the desired position 

이 완벽하지 않을 수 있지만 일반적인 생각