你好,我可以得到一个UITableView
来显示存储在文档文件夹中的图像的文件名。有没有办法让UICollectionView
在集合视图中显示这些图像?UICollectionView显示存储在文档目录中的图像
感谢利亚姆
你好,我可以得到一个UITableView
来显示存储在文档文件夹中的图像的文件名。有没有办法让UICollectionView
在集合视图中显示这些图像?UICollectionView显示存储在文档目录中的图像
感谢利亚姆
当然可以。这里是UICollectionView Programming Guide。
UICollectionView
+imageNamed:
方法与collectionView:cellForRowAtIndexPath:
返回小区。记得用UIImageView
在里面创建自定义单元格,创建outlet。
这里是Tutorial哪些应该可以帮到你。
// fetch all the files from the documents directory.
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
library = [path objectAtIndex:0];
fileArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:library error:nil];
NSArray *imagelist = [[NSArray alloc] init];
// filter the images from all the files.
for(int i = 0;i<fileArray.count;i++)
{
id object = [fileArray objectAtIndex:i];
if ([object rangeOfString:@".png"].location !=NSNotFound)
{
[imagelist addObject:object];
}
}
然后创建以下UICollectionView数据源在集合视图中添加项目集合查看和使用的情况下,
是的,有很多教程存在。 –