gpt4 book ai didi

ios - 跟随 UICollectionViewCell

转载 作者:行者123 更新时间:2023-11-29 12:29:09 27 4
gpt4 key购买 nike

我有一个 UICollectionView,它由单元格中的 UIImagePickerControl 按钮填充,我希望跟随 Collection View 末尾的单元格通过屏幕,但仍允许用户滚动

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
NSString* imageString = [image toString];
Screen * screen = [[Screen alloc]init];
screen.imageData = imageString;
[self.project.screens addObject:screen];
long long rowid = [self saveNewImageForScreenToDb:screen];
[self updateTitle:@"" atRowId:rowid];
[self updateTask:@"" atRowId:rowid];


[self dismissViewControllerAnimated:_picker completion:^{
[_collectionView reloadData];

}];

NSIndexPath * indexPath = [[NSIndexPath alloc]initWithIndex:?];
[self.collectionView scrollToItemAtIndexPath: indexPath.row =?
atScrollPosition:UICollectionViewScrollPositionRight
animated:YES];

}

这是选择器的代码,选择器是我的“UICollectioView”末尾的一个按钮。我必须插入什么 indexPath 才能让屏幕滚动到按钮所在的末尾

最佳答案

您会将选定的图像添加到 NSMutableArray 中。假设您的数组是 imagesArray。将 collectionView 滚动到 NSMutableArray 的最后一个对象。尝试在 didFinishPickingImage 方法下添加此代码。

[_collectionView reloadData];
NSIndexPath *bottomIndexPath=[NSIndexPath indexPathForRow:imagesArray.count-1 inSection:0];
[self.collectionView scrollToItemAtIndexPath: bottomIndexPath atScrollPosition:UICollectionViewScrollPositionRight animated:YES];

关于ios - 跟随 UICollectionViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28233299/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com