我已经在滚动视图中放置了动态创建的文本字段。我需要为滚动视图设置 contentOffset。在 textfield shouldbegin Editing 中,我给出了滚动视图。如果我遍历完成按钮,它工作正常。但是在中间,如果我点击任何文本字段,该文本字段就会上升,并且我看不到该文本字段。它显示下一个字段偏移量,但光标位于正确的文本字段中。我的代码是
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if(enteredHealthyHeart)
{
for(int i=0;i<[healthyHeart_TxtFldAry count];i++)
{
if(textField == [healthyHeart_TxtFldAry objectAtIndex:i])
{
getHHTag=textField.tag;
NSLog(@"getHHTag %i",getHHTag);
UITextField *tempTxtFld=[healthyHeart_TxtFldAry objectAtIndex:getHHTag];
if(i<([healthyHeart_TxtFldAry count]-1))
{
int j =tempTxtFld.frame.origin.y;
healthyHeartScrollView.contentOffset=CGPointMake(0 , j);
NSLog(@"j>>>>>%i",j);
}
if(i==([healthyHeart_TxtFldAry count]-1))
{
healthyHeartScrollView.contentOffset=CGPointMake(0 ,tempTxtFld.frame.origin.y);
}
[tempTxtFld resignFirstResponder];
return YES;
}
}
}
}
请帮我解决这个问题。