我有一个由单元格中的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才能让屏幕滚动到按钮所在的末尾
发布于 2015-02-02 11:57:42
您将将选定的图像添加到NSMutableArray
.Assume中,您的数组是imagesArray
。滚动collectionView
到NSMutableArray
的最后一个对象。尝试在didFinishPickingImage
方法下添加此代码。
[_collectionView reloadData];
NSIndexPath *bottomIndexPath=[NSIndexPath indexPathForRow:imagesArray.count-1 inSection:0];
[self.collectionView scrollToItemAtIndexPath: bottomIndexPath atScrollPosition:UICollectionViewScrollPositionRight animated:YES];
https://stackoverflow.com/questions/28233299
复制相似问题