123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- //
- // 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 ()<UICollectionViewDataSource,UICollectionViewDelegate>
- {
- 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];
- // markInfo *mark = marksArray[_markTag];
- // self.title = mark.title;
-
- 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.height -= kNavOffSet;
- 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)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- {
- //标题显示有问题
- myDelegate.layoutIndex = indexPath.row;
- layout.isCan = YES;
- // markInfo *mark = marksArray[indexPath.row];
- // self.title = mark.title;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|