2

UIViewController含む がありUIScrollViewます。最初automaticallyAdjustsScrollViewInsetsは設定されていません(したがって、デフォルトで に設定する必要がありますYES)。

一部のユーザー インタラクションでは、 に設定automaticallyAdjustsScrollViewInsetsしたため、スクロール ビューでNO独自の設定を行うことができます。contentInset

その後、何も起こりません。後で何に電話すればいいですか?

スクロール ビューを呼び出しsetNeedsDisplayても役に立ちません。

4

1 に答える 1

2

If you want your initial display of your scrollview to include an initial content offset, then set the contentInset value in viewDidLoad. If you wish to dynamically change the contentInset and have the contentOffset change as well, then you need to adjust the contentOffset at the same time as the contentInset. For example:

// 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];
}
于 2014-03-24T22:20:23.820 に答える