//首先创建一个Model层写入一个可变数组 读入plist文件
-(NSMutableArray*)geturl;
-(NSMutableArray*)geturl
{
return [NSMutableArray arrayWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"1" ofType:@"plist"]];
}
//使用XRWaterfallLayout布局流
-(UICollectionView*)coll
{
if (!_coll)
{
self.layot=[XRWaterfallLayout waterFallLayoutWithColumnCount:2];
[self.layot setColumnSpacing:3 rowSpacing:4 sectionInset:UIEdgeInsetsMake(5, 5, 5, 5)];
_coll=[[UICollectionView alloc]initWithFrame:self.bounds collectionViewLayout:self.layot];
_coll.backgroundColor = [UIColor whiteColor];
[_coll registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
}
return _coll;
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.arr1 = [[Model alloc] geturl];
NSLog(@"%@",self.arr1);
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(click:)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(click1:)];
}
-(CGFloat)waterfallLayout:(XRWaterfallLayout *)waterfallLayout itemHeightForWidth:(CGFloat)itemWidth atIndexPath:(NSIndexPath *)indexPath
{
return [[self.arr2[indexPath.row]objectForKey:@"h"]floatValue]/[[self.arr2[indexPath.row]objectForKey:@"w"]floatValue]*itemWidth;
}
- (void)viewDidLoad {
[super viewDidLoad];
_coll=[[wangge alloc]initWithFrame:self.view.bounds];
self.view=_coll;
_coll.backgroundColor = [UIColor whiteColor];
_coll.coll.delegate=self;
_coll.coll.dataSource=self;
_coll.layot.delegate=self;
}
-(void)click:(UIBarButtonItem*)sender
{
if (self.arr2.count
网友评论