0

我有一个滚动视图,里面有一个 UITextfield。当键盘出现时,我使用 setContentOffset: animated: 滚动滚动视图。但是,当按下返回按钮到 popViewControllerAnimated: 时,滚动视图会向下滚动。我希望在弹出视图时滚动位置保持不变。知道如何让它正常工作吗?

谢谢!

// Called when the UIKeyboardDidShowNotification is sent.
- (void)keyboardWasShown:(NSNotification*)aNotification
{

...

// If active text field is hidden by keyboard, scroll it so it's visible
CGRect aRect = CGRectMake(0, 0, 320, 460-44-215);
aRect.size.height -= kbSize.height;
if (!CGRectContainsPoint(aRect, activeField.frame.origin) ) {
    CGPoint scrollPoint = CGPointMake(0.0, activeField.frame.origin.y-80);
    [sv setContentOffset:scrollPoint animated:YES];
}
}
4

0 回答 0