我正在创建一个Objective-C iOS应用程序,它具有全屏水平滚动UICollectionView
图像。
每当UICollectionView
加载完内容时,如何创建在UICollectionView
的第一个单元格上调用的函数?
答案 0 :(得分:0)
试试这个
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
if (indexPath.row == 0) {
callFunction()
}
return cell;
}
或者如果您正在下载图像,则可以在完成块中调用该功能
答案 1 :(得分:0)
我想你想滚动到第一项,你可以拨打scrollToItemAtIndexPath
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.collectionView scrollToItemAtIndexPath:indexPath
atScrollPosition:UICollectionViewScrollPositionLeft
animated:YES];