2011-05-13 5 views
0

에 UITable 스크롤 텍스트 필드 나는 UITableView에서 UITextField을 가지고 있고 나는 UITextField 클릭하고 때 그때는 오프셋 이동 한, 그러나 다음 필드로 사용자가 스크롤 한 후 약간의 시간 입력 새로 고침 이상한 행동을 보여 때 내 질문입니다 초점이 이전 UITextField으로 되돌아갑니다.키보드

+0

@ user321373 : Jhaliya가 답변을 수락하고 나는 귀하의 질문을 수정하는 중 하나라고 말했고 귀하의 문제는 여전히 해결되지 않았습니다. –

답변

0

UR 프로젝트에 따르면, 코드와 impelement 참조

  • (BOOL) textFieldShouldBeginEditing (의 UITextField *)에 textField {

    [자기 scrollViewToCenterOfScreen : TextField 구성];
    return 예;

  • }
  • (공극) scrollViewToCenterOfScreen (UIView의 *) theView {
    CGFloat viewCenterY = theView.center.y;
    CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];

    CGFloat availableHeight = applicationFrame.size.height - 200; // 키보드가 덮는 부분을 제거하십시오.

    CGFloat y = viewCenterY - availableHeight/2.0;
    if (y < 0) {
    y = 0;
    }
    [scrollview setContentOffset : CGPointMake (0, y) animated : YES];

}

- (BOOL) textFieldShouldReturn : (UITextField에 *)에 textField {

if ([textField isEqual:txtStAppField]) 
{ 
    [txtStConfirmField becomeFirstResponder]; 
} 
else if ([textField isEqual:txtStConfirmField]) 
{ 
    [txtDummyAppField becomeFirstResponder]; 
} 
else if ([textField isEqual:txtStConfirmField]) 
{ 
    [txtDummyConfirmFeild becomeFirstResponder]; 
} 
else 
{ 
    [textField resignFirstResponder];  
    [scrollview setContentOffset:CGPointMake(0, 0) animated:YES]; 
} 

return YES; 

}

// txtStConfirmField, txtDummyConfirmFeild, txtDummyAppField, txtStConfirmField, txtStConfirmField는 tectField 있습니다 이름.