美文网首页
本地plist文件实现瀑布流照片墙

本地plist文件实现瀑布流照片墙

作者: Anday_ | 来源:发表于2017-06-29 20:25 被阅读0次

    本地plist文件实现瀑布流照片墙

    @property (nonatomic,strong) NSMutableArray *plistArray;

    @property (nonatomic,strong) NSMutableArray *showArray;

    @property (nonatomic,copy) UICollectionView *theCollectionView;

    两个可变数组用来存放图片,

    -(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];

    网格设置

    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"Add" style:UIBarButtonItemStylePlain target:self action:@selector(add:)];    

    _showArray=[NSMutableArray new];

    初始化用来展示图片的数组,导航右按钮,

    点击导航栏又按钮添加图片方法 layout代理计算item高度 单元格内容,在cell里赋值 CollectionViewCell单元格内拖拽UIImageView和UILable CollectionViewCell.m里进行赋值 Model.h

    相关文章

      网友评论

          本文标题:本地plist文件实现瀑布流照片墙

          本文链接:https://www.haomeiwen.com/subject/rzjvcxtx.html