以下代码可以在
UICollectionView
中向右滚动到正确的单元格,但是在我的情况下,区域头视图被UINavigationBar
遮挡了。我相信我应该使用scrollRectToVisible
,我的问题是,在给定的section
中numberOfRows
是可变的时候,如何正确计算CGRect
(y位置)。- (void)scrollToPricing:(NSUInteger)row {
[self.collectionView scrollToItemAtIndexPath:
[NSIndexPath indexPathForItem:0
inSection:row]
atScrollPosition:UICollectionViewScrollPositionTop
animated:YES];
}