本地plist文件實(shí)現(xiàn)瀑布流照片墻
@property (nonatomic,strong) NSMutableArray *plistArray;
@property (nonatomic,strong) NSMutableArray *showArray;
@property (nonatomic,copy) UICollectionView *theCollectionView;
兩個可變數(shù)組用來存放圖片,
-(NSMutableArray *)plistArray{
if (!_plistArray) {
_plistArray=[[NSMutableArray alloc]init];
}
NSString *path=[[NSBundle mainBundle]pathForResource:@"photos" ofType:@"plist"];
NSDictionary *dic=[NSDictionary dictionaryWithContentsOfFile:path];
for (NSDictionary *dic_22 in dic[@"content"]) {
PlistModel *plist=[[PlistModel alloc]init];
[plist setValuesForKeysWithDictionary:dic_22];
[_plistArray addObject:plist];
}
return _plistArray;
}
獲取圖片資源
YCCollectionViewLayout文件未上傳
YCCollectionViewLayout *layout=[[YCCollectionViewLayout alloc]initWithCloumnCount:3];
[layout setCloumnSpacingWidth:5 rowSpacingHeight:5 borderSet:UIEdgeInsetsMake(5, 5, 5, 5)];
layout.delegate=self;
_theCollectionView=[[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:layout];
_theCollectionView.delegate=self; ? ?_theCollectionView.dataSource=self;
_theCollectionView.backgroundColor=[UIColor whiteColor];
[_theCollectionView registerNib:[UINib nibWithNibName:@"PlistCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"a"];
[self.view addSubview:self.theCollectionView];
網(wǎng)格設(shè)置
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"Add" style:UIBarButtonItemStylePlain target:self action:@selector(add:)]; ? ?
_showArray=[NSMutableArray new];
初始化用來展示圖片的數(shù)組还绘,導(dǎo)航右按鈕窑眯,