Iphone popviewcontroller重置scrollview内容偏移量
我有一个滚动视图,里面有一个UITextfield。当键盘出现时,我使用setContentOffset:animated:滚动滚动视图。但是,当按下“后退”按钮至popViewControllerAnimated:,scrollview将向下滚动。我希望在弹出视图时滚动位置保持不变。你知道如何让它正常工作吗 谢谢Iphone popviewcontroller重置scrollview内容偏移量,iphone,objective-c,ios,Iphone,Objective C,Ios,我有一个滚动视图,里面有一个UITextfield。当键盘出现时,我使用setContentOffset:animated:滚动滚动视图。但是,当按下“后退”按钮至popViewControllerAnimated:,scrollview将向下滚动。我希望在弹出视图时滚动位置保持不变。你知道如何让它正常工作吗 谢谢 // Called when the UIKeyboardDidShowNotification is sent. - (void)keyboardWasShown:(NSNotif
// 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];
}
}
在我看来,你辞职的文本字段第一响应者状态太早。谢谢,我让它工作。把你的答案加上,我会记下来的。