【发布时间】:2017-08-14 11:23:50
【问题描述】:
我正在尝试通过以下代码滚动我的应用程序中屏幕外的UICollectionView。
int pages = ceil(aCollectionView.contentSize.height / aCollectionView.frame.size.height);
for (int i = 0; i < pages; i ++)
{
NSArray *sortedVisibleItems = [[aCollectionView indexPathsForVisibleItems] sortedArrayUsingSelector:@selector(compare:)];
NSIndexPath *lastItem = [sortedVisibleItems lastObject];
// 2.next position
NSInteger nextItem = lastItem.item + 1;
NSInteger nextSection = lastItem.section;
NSIndexPath *nextIndexPath = [NSIndexPath indexPathForItem:nextItem inSection:nextSection];
[self takeImage];
dispatch_async(dispatch_get_main_queue(), ^
{
[aCollectionView scrollToItemAtIndexPath:nextIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO];
});
}
并为打印目的拍摄每一页的屏幕截图。 但它不滚动并且总是多次打印第一页。
UICollectionView 的属性
我错过了还是做错了方向?
【问题讨论】:
标签: ios objective-c uicollectionview