Ios 设置contentInset或AutomaticallyAdjustsScrollViewInset后,我必须做什么才能使其实际应用?

Ios 设置contentInset或AutomaticallyAdjustsScrollViewInset后,我必须做什么才能使其实际应用?,ios,ios7,uiscrollview,setneedsdisplay,insets,Ios,Ios7,Uiscrollview,Setneedsdisplay,Insets,我有一个UIViewController包含UIScrollView。最初未设置automaticallyadjustsscrollviewsinsets(因此它应默认为YES) 在某些用户交互中,我将自动调整滚动视图插入设置为否,这样我就可以在滚动视图上设置自己的内容插入 这样做之后,什么也没有发生。之后我要打什么电话 在滚动视图上调用setNeedsDisplay没有帮助。如果希望滚动视图的初始显示包含初始内容偏移量,请在viewDidLoad中设置contentInset值。 如果希望动态

我有一个
UIViewController
包含
UIScrollView
。最初未设置
automaticallyadjustsscrollviewsinsets
(因此它应默认为
YES

在某些用户交互中,我将
自动调整滚动视图插入设置为
,这样我就可以在滚动视图上设置自己的
内容插入

这样做之后,什么也没有发生。之后我要打什么电话


在滚动视图上调用
setNeedsDisplay
没有帮助。

如果希望滚动视图的初始显示包含初始内容偏移量,请在
viewDidLoad
中设置contentInset值。 如果希望动态更改contentInset并同时更改contentOffset,则需要在调整contentInset的同时调整contentOffset。例如:

// Adjust content inset and initial offset to account for the header
UIEdgeInsets contentInset = self.collectionView.contentInset;
contentInset.top += self.stickyHeaderView.bounds.size.height;
self.collectionView.contentInset = contentInset;
if (-1 * self.collectionView.contentOffset.y < contentInset.top) {
    CGPoint contentOffset = self.collectionView.contentOffset;
    contentOffset.y = -1*contentInset.top;
    [self.collectionView setContentOffset:contentOffset animated:YES];
}
//调整内容插入和初始偏移量以考虑标题
UIEdgeInsets contentInset=self.collectionView.contentInset;
contentInset.top+=self.stickyHeaderView.bounds.size.height;
self.collectionView.contentInset=contentInset;
如果(-1*self.collectionView.contentOffset.y