我有一个由单元格中的UICollectionView
按钮填充的UIImagePickerControl
,我希望屏幕后面跟随集合视图末尾的单元格,但仍允许用户滚动
- (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/