// // DetailMarkVC.m // jiaPei // // Created by apple on 16/1/13. // Copyright © 2016年 JCZ. All rights reserved. // #import "DetailMarkVC.h" #import "markInfo.h" #import "RGCardViewLayout.h" #import "DetailMarkCell.h" @interface DetailMarkVC () { NSArray *marksArray; UICollectionView *collection; RGCardViewLayout *layout; } @end @implementation DetailMarkVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = backGroundColor; [self configNavigationBar]; self.title = @"标志详情"; marksArray = [NSArray arrayWithArray:_dataArray]; myDelegate.layoutIndex = _markTag; [self myInit]; } -(void)myInit { layout = [[RGCardViewLayout alloc] init]; [layout setScrollDirection:UICollectionViewScrollDirectionVertical]; CGFloat width = kFrame.size.width - 30; CGFloat hight = kFrame.size.height - 100; [layout setItemSize:CGSizeMake(width, hight)]; [layout setSectionInset:UIEdgeInsetsMake(30, 15, 30, 15)]; layout.isCan = YES; collection = [[UICollectionView alloc] initWithFrame:kFrame collectionViewLayout:layout]; collection.delegate = self; collection.dataSource = self; collection.backgroundColor = backGroundColor; [collection setPagingEnabled:YES]; [self.view addSubview:collection]; [collection registerClass:[DetailMarkCell class] forCellWithReuseIdentifier:@"detailCell"]; [collection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:_markTag] atScrollPosition:(UICollectionViewScrollPositionCenteredHorizontally) animated:false]; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 1; } - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return marksArray.count; } -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { DetailMarkCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"detailCell" forIndexPath:indexPath]; for (int i = 0; i < marksArray.count; i++) { markInfo *info = marksArray[indexPath.section]; cell.imgView.image = [UIImage imageNamed:info.imageName]; cell.titleLabel.text = info.title; cell.detailLabel.text = info.detail; } return cell; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end