UIScrollView内容插入重置不工作iOS8/9

UIScrollView内容插入重置不工作iOS8/9,ios,objective-c,uiscrollview,Ios,Objective C,Uiscrollview,显示/隐藏键盘时,我使用以下命令: - (void)keyboardWasShown:(NSNotification *)notification { NSDictionary *info = [notification userInfo]; CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; UIEdgeInsets contentInsets =

显示/隐藏键盘时,我使用以下命令:

- (void)keyboardWasShown:(NSNotification *)notification
{
    NSDictionary *info = [notification userInfo];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

    UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
    self.scrDetails.contentInset = contentInsets;
    self.scrDetails.scrollIndicatorInsets = contentInsets;
}

- (void)keyboardWillHide:(NSNotification *)notification
{
    /* Set to NO so after the keyboard is hidden, the size goes back to normal */
    self.automaticallyAdjustsScrollViewInsets = NO;

    UIEdgeInsets contentInsets = UIEdgeInsetsZero;
    self.scrDetails.contentInset = contentInsets;
    self.scrDetails.scrollIndicatorInsets = contentInsets;

    [self.view layoutIfNeeded];
}
但出于某种原因,即使在关闭键盘时大小设置正确

(lldb) po self.scrDetails.contentInset
 (top = 0, left = 0, bottom = 0, right = 0)
设备/模拟器上未显示该效果(滚动条保持在先前的键盘向上位置)

看到图片了吗

我使用自动布局,所以我不直接设置contentSize


有什么建议可以帮助追踪此信息吗?

您可以使用第三方类TPKeyboard。它管理键盘


链接:

您可以使用第三方类TPKeyboard。它管理键盘


链接:

谢谢。我知道,但在这种情况下,我想解决这个特殊问题。谢谢。我知道,但在这种情况下,我想解决这个特定问题。我遇到了相同的问题,您是否找到了解决方案?我遇到了相同的问题,您是否找到了解决方案?