| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590 |
- //
- // SearchViewController.m
- // shiku_im
- //
- // Created by huangyp-pc on 16/2/24.
- // Copyright © 2016年 Reese. All rights reserved.
- //
- #import "SearchViewController.h"
- #import "SearchCell.h"
- //#import "ScheduleTableViewController.h"
- #import "OrderFormTableViewController.h"
- #import "StatisticDoubleListViewController.h"
- #import "DoubleListCell.h"
- #import "PieCharViewController.h"
- #import "DataItemCharViewController.h"
- #import "Config.h"
- #import "GMDCircleLoader.h"
- static NSString *cellID = @"cellID";
- @interface SearchViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic,strong) UICollectionView *grid;
- @property (nonatomic,assign) int count; //每行多少个item
- @property (nonatomic,strong) UIButton *chaxunBtn;
- @property (nonatomic,strong) UIButton *tongjiBtn;
- @property (nonatomic,strong) NSArray *imageArr;
- @end
- @implementation SearchViewController
- {
- NSMutableArray* allSearchMenu;
- UIColor *addingCellBackColor;
- NSMutableArray *menuViewDataArray;
-
- UISegmentedControl *segmentedControl;
-
- //doubleList
- UASNetworkManager *DoublistNetManager;
- NSArray *datasAllKeys;
- BOOL isHadOpen;
- NSInteger innum;
- ////
- NSDictionary *doubleAllDataDic;
- ////
- NSArray * arrayTest;
- DoubleListCell *preCell;
-
- UASNetworkManager *searchMenuViewManager;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- //初始化数据
- _count = 3;
- menuViewDataArray=[[NSMutableArray alloc] init];
- allSearchMenu=[[NSMutableArray alloc]init];
-
- addingCellBackColor=[UIColor whiteColor];
- self.view.backgroundColor = addingCellBackColor;
-
- _imageArr = @[@"uu_work_kucunchaxun",@"uu_work_dingdanchaxun",@"uu_work_caigouchaxun",@"uu_work_feiyongbaoxiao",@"uu_work_xiaoshoufahuo",@"uu_work_qingjiadanchaxun",@"uu_work_yingshoufapiao",@"uu_work_chalvfeibaoxiao",@"uu_work_qinggouchaxun",@"uu_work_caigouruku",@"uu_work_jipiaoyuding",@"uu_work_fahuotongzhi",@"uu_work_yingfufapiao"];
-
- [self getDataFromSever];
- [self initGridView]; //设置查询页面
-
-
- _chaxunBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _chaxunBtn.frame = CGRectMake(0, 0, 65, 30);
- [_chaxunBtn setBackgroundImage:[UIImage imageNamed:@"uu_work_chaxun_normal"] forState:UIControlStateNormal];
- [_chaxunBtn setBackgroundImage:[UIImage imageNamed:@"uu_work_chaxun_press"] forState:UIControlStateDisabled];
- _chaxunBtn.enabled = NO;
- [_chaxunBtn addTarget:self action:@selector(changeChaxunViewController) forControlEvents:UIControlEventTouchUpInside];
-
- _tongjiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _tongjiBtn.frame = CGRectMake(65, 0, 65, 30);
- [_tongjiBtn setBackgroundImage:[UIImage imageNamed:@"uu_work_tongji_normal"] forState:UIControlStateNormal];
- [_tongjiBtn setBackgroundImage:[UIImage imageNamed:@"uu_work_tongji_press"] forState:UIControlStateDisabled];
- _tongjiBtn.enabled = YES;
- [_tongjiBtn addTarget:self action:@selector(changeTongjiViewController) forControlEvents:UIControlEventTouchUpInside];
-
-
- UIImageView *testimage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 130, 30)];
- testimage.userInteractionEnabled = YES;
-
- [testimage addSubview:_chaxunBtn];
- [testimage addSubview:_tongjiBtn];
-
- NSArray *segmentedArray = @[@"查询",@"统计"];
- segmentedControl = [[UISegmentedControl alloc]initWithItems:segmentedArray];
- segmentedControl.frame = CGRectMake(0, 0, self.view.bounds.size.width/2, 36);
- segmentedControl.selectedSegmentIndex = 0;
- UIColor *color = [UIColor colorWithRed:13/255.0 green:143/255.0 blue:219/255.0 alpha:255/255.0];
- segmentedControl.tintColor = color;
- //[segmentedControl addTarget:self action:@selector(changeViewController:) forControlEvents:UIControlEventValueChanged];
-
- [self.navigationItem setTitleView:testimage];
-
- //设置统计页面
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height-64)];
- _tableView.delegate=self;
- _tableView.dataSource=self;
- [self initDoubleListTable];
- _tableView.hidden=YES;
- [self.view addSubview:_tableView];
-
- // UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
- // btn.frame = CGRectMake(-10, 0, 60, 30);
- // [btn setTitle:@"< 返回" forState:UIControlStateNormal];
- // [btn setBackgroundColor:[UIColor clearColor]];
- // [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- // [btn addTarget:self action:@selector(backToView) forControlEvents:UIControlEventTouchUpInside];
- //
- // UIBarButtonItem *leftBBI = [[UIBarButtonItem alloc] initWithCustomView:btn];
- // self.navigationItem.leftBarButtonItem = leftBBI;
-
-
- //消息通知(切换帐套)
- [[NSNotificationCenter defaultCenter] removeObserver:self name:@"mytest" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mytest:) name:@"mytest" object:nil];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:@"hideBottomView" object:nil];
-
- }
- -(void)backToView
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [GMDCircleLoader hideFromView:self.view animated:YES];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [[NSNotificationCenter defaultCenter] postNotificationName:@"hideBottomView" object:nil];
- }
- -(void)changeChaxunViewController
- {
- _chaxunBtn.enabled = NO;
- _tongjiBtn.enabled = YES;
- _tableView.hidden = YES;
- }
- -(void)changeTongjiViewController
- {
- _chaxunBtn.enabled = YES;
- _tongjiBtn.enabled = NO;
- _tableView.hidden = NO;
- }
- -(void)changeViewController:(id)sender
- {
- UISegmentedControl* control = (UISegmentedControl*)sender;
- switch (control.selectedSegmentIndex) {
- case 0:
- _tableView.hidden=YES;
- break;
- case 1:
- _tableView.hidden=NO;
- break;
- default:
- break;
- }
- }
- -(void)mytest:(NSNotification*) notification
- {
- [self getDataFromSever];
- [self GetDatasFromSever];
- [self.grid reloadData];
- }
- -(void)getDataFromSever
- {
- searchMenuViewManager=[UASNetworkManager shareManager];
- searchMenuViewManager.responseSerializer=[AFHTTPResponseSerializer serializer];
- NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];
- NSString *sessionId=[userDefaults stringForKey:@"sessionId"];
- NSString *ip=[userDefaults objectForKey:@"ipAndPort"];
- NSString *urlStr1=[@"" stringByAppendingFormat: @"%@mobile/common/getMobileQuerys.action?sessionId=%@",ip,sessionId];
-
- //__block NSDictionary *objectDetailArr;
- DLog(@"开始请求数据!!!!");
- //NSMutableDictionary *params=@{@"Page":@"2"};
- NSString *params=@"";
- DLog(@"search urlStr=%@",urlStr1);
- [searchMenuViewManager.requestSerializer setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
-
- NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
- [searchMenuViewManager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
- [searchMenuViewManager request:urlStr1 method:POST parameters:params progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- DLog(@"成功!");
- [GMDCircleLoader hideFromView:self.view animated:YES];
- NSData *data=responseObject;
- id tempDic=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
- menuViewDataArray=[tempDic objectForKey:@"querys"];
- if ([menuViewDataArray isKindOfClass:[NSNull class]]) {
- DLog(@"没有数据~~~~~~~~~~~~~~~~~~~~~~~~~~~");
- }else
- {
- allSearchMenu=[NSMutableArray arrayWithArray:menuViewDataArray];
-
- }
- [_grid reloadData];
- DLog(@"hypishandsomedataall========%@",menuViewDataArray);
- DLog(@"allSearchMenu:%lu",(unsigned long)allSearchMenu.count);
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
- DLog(@"失败 !hkjhkjhjjjjjjjjjjjjjjjjjjjjjj:%@",error);
- [GMDCircleLoader hideFromView:self.view animated:YES];
- }];
- }
- -(void)GetDatasFromSever
- {
- DoublistNetManager=[UASNetworkManager shareManager];
- DoublistNetManager.responseSerializer=[AFHTTPResponseSerializer serializer];
- NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];
- NSString *sessionId=[userDefaults stringForKey:@"sessionId"];
- NSString *ip=[userDefaults stringForKey:@"ipAndPort"];
- NSString *urlStr1=[@"" stringByAppendingFormat:@"%@mobile/common/Stats.action?sessionId=%@",ip,sessionId];
- DLog(@"开始请求数据!!!!");
- NSString *params=@"";
- DLog(@"urlStr=%@",urlStr1);
- [DoublistNetManager request:urlStr1 method:POST parameters:params progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- DLog(@"成功了吗?????");
- [GMDCircleLoader hideFromView:self.view animated:YES];
- NSData *data=responseObject;
- _TableArry = [[NSMutableArray alloc]init];
- id dic=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
- preCell=nil;
- doubleAllDataDic=[dic objectForKey:@"Stats"];
- [self parseDatas];
- [_tableView reloadData];
- if (doubleAllDataDic.count == 0) {
- DLog(@"空了你不知道????");
- [self showNoDataView];
- }
- DLog(@"data=%@",doubleAllDataDic);
- DLog(@"hypishandsomelalala:%@",dic);
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
- DLog(@"失败 !:%@",error);
- }];
- innum++;
- DLog(@"innum>>>>>>>>>>>>>>>>>>>>>>>>>>>>=%ld",(long)innum);
- }
- //数据解析
- -(void)parseDatas
- {
- datasAllKeys=[doubleAllDataDic allKeys];
- for (int i=0; i<[datasAllKeys count]; i++) {
- DoubleListCell *cell=[[DoubleListCell alloc] init:NO];
- NSArray *array=[doubleAllDataDic objectForKey:[datasAllKeys objectAtIndex:i]] ;
- NSMutableArray *childArray = [[NSMutableArray alloc] init];
- for (int m =0;m<[array count];m ++) {
- DoubleListCell *childCell=[[DoubleListCell alloc] init:YES];
- childCell.Name.text=[[array objectAtIndex:m] objectForKey:@"st_title"];
- childCell.type= [[array objectAtIndex:m] objectForKey:@"st_type"];
- childCell.cellId= [NSString stringWithFormat:@"%@",[[array objectAtIndex:m] objectForKey:@"st_id"]] ;
- childCell.ChildArray=nil;
- [childArray addObject:childCell];
- }
- cell.Name.text =[datasAllKeys objectAtIndex:i];
- cell.ChildArray=childArray;
- [_TableArry addObject:cell];
- }
- }
- //显示暂无数据
- -(void)showNoDataView
- {
- UILabel *noDataLbl = [[UILabel alloc]initWithFrame:self.view.frame];
- noDataLbl.center = self.view.center;
- noDataLbl.text = @"对不起!暂无数据!";
- noDataLbl.textColor = [UIColor lightGrayColor];
- noDataLbl.font = [UIFont boldSystemFontOfSize:18];
- noDataLbl.textAlignment = NSTextAlignmentCenter;
- [self.tableView addSubview:noDataLbl];
-
- }
- /******************************统计页面*************************************/
- -(void)initDoubleListTable
- {
- innum = 0;
- preCell = nil;
- _TableArry = [[NSMutableArray alloc] init];
- _InsertArry = [[NSMutableArray alloc] init];
- _DeleteArry = [[NSMutableArray alloc] init];
- isHadOpen = NO;
-
- //设置背景
- UIImageView *backImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
- [backImageView setImage:[UIImage imageNamed:@""]];
- self.tableView.backgroundView = backImageView;
- self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
-
-
- UIImageView *testd = [[UIImageView alloc]initWithFrame:self.view.bounds];
- testd.image = [UIImage imageNamed:@"uu_background_huibai"];
- self.tableView.backgroundView = testd;
-
- //向页面添加一个 加载动画
- [GMDCircleLoader setOnView:self.view withTitle:@"Loading" animated:YES];
- [self GetDatasFromSever];
-
- //设置切换帐套的监听
- //[[NSNotificationCenter defaultCenter] removeObserver:self name:@"mytest" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mytest:) name:@"mytest" object:nil];
- }
- #pragma mark -- tableView delegate
- //返回tableView中cell的个数
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return _TableArry.count;
- }
- //设置 cell 的样式
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- UITableViewCell *cell = [[DoubleListCell alloc] init];
- if (indexPath.row < _TableArry.count)
- {
- cell = [_TableArry objectAtIndex:indexPath.row];
- }
- if (indexPath.row%2 == 0) {
- cell.backgroundColor = [UIColor colorWithRed:160/255.0 green:160/255.0 blue:160/255.0 alpha:0.1];
- }else
- {
- cell.backgroundColor = [UIColor clearColor];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- //返回cell的高度
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 55;
- }
- //当cell被选择(被点击)时调用的函数
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- DoubleListCell *cell = [_TableArry objectAtIndex:indexPath.row];
- {
- if (!cell.Open)//如果子菜单是关闭的
- {
- double delayInSeconds = 0.0f;
- if (preCell!=cell && preCell.Open && cell.ChildArray.count!=0) {
- delayInSeconds = 0.3;
- [self closeWithIndex:[_TableArry indexOfObject:preCell] tableView:tableView isAnimation:NO];
- preCell.Open = NO;
- [UIView animateWithDuration:0.2 animations:^{
- if (preCell.Open) {
- preCell.iconView.transform = CGAffineTransformMakeRotation(M_PI);
- }
- else
- {
- preCell.iconView.transform = CGAffineTransformMakeRotation(0);
- }
- } completion:^(BOOL finished) {
-
- }];
- }
- NSArray * array = [self insertOperation:cell];
- dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
- dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
- //[self openWithIndex:[m_datas indexOfObject:m] tableView:tableView isAnimation:NO];
- [self.tableView insertRowsAtIndexPaths: array withRowAnimation:UITableViewRowAnimationBottom ];
- //cell.Open = YES;
- });
- isHadOpen=YES;
- }
- else//如果子菜单是打开的
- {
- NSArray *array = [self deleteOperation:cell];
- if (array.count > 0 )
- {
- //从视图中删除
- [self.tableView deleteRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationBottom];
- }
- }
- }
-
- if (cell.ChildArray.count == 0)
- {
-
- UIStoryboard *testStoryboard = [UIStoryboard storyboardWithName:@"Test" bundle:[NSBundle mainBundle]];
-
-
- if ([[cell GetType] intValue] == 1)
- {
- DataItemCharViewController *dataItemCharView = [[DataItemCharViewController alloc] init];
- dataItemCharView.m_id = cell.cellId;
- dataItemCharView.m_titile = cell.Name.text;
-
- if ([cell.Name.text isEqualToString:@"销售额按天统计"]) {
- dataItemCharView.isDay = @"YES";
- }else
- {
- dataItemCharView.isDay = @"NO";
- }
-
- [self.navigationController pushViewController:dataItemCharView animated:YES];
- }
- else
- {
- PieCharViewController *pieCharVC = [testStoryboard instantiateViewControllerWithIdentifier:@"pieCharView"];
- pieCharVC.m_id = cell.cellId;
- pieCharVC.m_title = cell.Name.text;
- [self.navigationController pushViewController:pieCharVC animated:YES];
- }
- }
- else
- {
- [UIView animateWithDuration:0.2 animations:^{
- if (cell.Open) {
- cell.iconView.transform = CGAffineTransformMakeRotation(M_PI);
- }else
- {
- cell.iconView.transform = CGAffineTransformMakeRotation(0);
- }
- } completion:^(BOOL finished) {
-
- }];
- }
-
- }
- -(void)closeWithIndex:(NSInteger)index tableView:(UITableView*)tableView isAnimation:(BOOL)animation
- {
- DoubleListCell* m = _TableArry[index];
- NSMutableArray* indexPathArray = [NSMutableArray array];
- for (int i = 1; i <= m.ChildArray.count; i++) {
- NSIndexPath* subIndexPath = [NSIndexPath indexPathForRow:index+i inSection:0];
- [indexPathArray addObject:subIndexPath];
- }
- NSRange range;
- range.length = m.ChildArray.count;
- range.location = index+1;
- NSIndexSet* indexSet = [NSIndexSet indexSetWithIndexesInRange:range];
- [_TableArry removeObjectsAtIndexes:indexSet];
- if (animation) {
- [tableView deleteRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationFade];
- }
- else
- [tableView deleteRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationNone];
- }
- -(NSArray *) insertOperation:(DoubleListCell *)item
- {
- [_InsertArry removeAllObjects];//将插入菜单清空
- NSIndexPath *path = [NSIndexPath indexPathForRow:[_TableArry indexOfObject:item] inSection:0];//获取选取的cell的位置
- DoubleListCell *child = [[DoubleListCell alloc]init];
- //遍历当前选取cell 的子菜单
- for(int i=0;i<item.ChildArray.count;i++)
- {
- child = [item.ChildArray objectAtIndex:i];
- [_TableArry insertObject:child atIndex:path.row + i +1 ];//调用数组函数将其插入其中
- [_InsertArry addObject:child];//放入插入数组中
- }
- item.Open=YES;//设置菜单已经打开
- NSMutableArray *PathArray= [NSMutableArray array];//初始化用于存放位置的数组
- for(DoubleListCell * cell in _InsertArry)
- {
- NSIndexPath *path = [NSIndexPath indexPathForRow:[_TableArry indexOfObject:cell] inSection:0];
- [PathArray addObject:path];
- }
- return PathArray;
- }
- -(NSArray *) deleteOperation:(DoubleListCell *)item
- {
- [_DeleteArry removeAllObjects];//清空删除数组
- DoubleListCell *child =[[DoubleListCell alloc]init];//子菜单
- for(int i =0;i<item.ChildArray.count;i++)
- {
- child = [item.ChildArray objectAtIndex:i];
- [_DeleteArry addObject:child];//添加到删除数组
- }
- item.Open = NO;//设置子视图关闭
- NSMutableArray *mutableArry = [NSMutableArray array];
- NSMutableIndexSet *set= [NSMutableIndexSet indexSet];//设置用来存放删除的cell的索引
- for(DoubleListCell *cell in _DeleteArry)
- {
- NSIndexPath *path = [NSIndexPath indexPathForRow:[_TableArry indexOfObject:cell] inSection:0];
- DLog(@"%ld",(long)path.row);
- [mutableArry addObject:path];
- [set addIndex:path.row];
- }
- [_TableArry removeObjectsAtIndexes:set];//调用函数来从数组中删除
- return mutableArry;
- }
- /******************************查询页面*************************************/
- -(void)initGridView
- {
- UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
-
- _grid = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
- _grid.dataSource = self;
- _grid.delegate = self;
- [self.view addSubview:_grid];
- //_grid.backgroundColor = addingCellBackColor;
-
- UIImageView *testd = [[UIImageView alloc]initWithFrame:self.view.bounds];
- testd.image = [UIImage imageNamed:@"uu_background_huibai"];
- _grid.backgroundView = testd;
-
- [_grid registerClass:[SearchCell class] forCellWithReuseIdentifier:cellID];
- }
- #pragma mark - UICollectionView 代理
- //有多少个单元格
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- DLog(@"你确定先执行吗?????");
- //DLog(@"可以的:%lu",(unsigned long)allSearchMenu.count);
- return allSearchMenu.count;
- }
- //每个item的内容
- -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- SearchCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
-
-
- cell.nameLbl.text = [NSString stringWithFormat:@"%@",[[allSearchMenu objectAtIndex:indexPath.row] objectForKey:@"mq_title"]];
- DLog(@"whatthefuck:%@",[[menuViewDataArray objectAtIndex:indexPath.row] objectForKey:@"mq_title"]);
-
- cell.searchImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",_imageArr[indexPath.row]]];
-
- // cell.layer.borderColor=[UIColor darkGrayColor].CGColor;
- // cell.layer.borderWidth=2.0;
-
- // cell.nameLbl.text = @"123";
-
- return cell;
- }
- //设置每个item的大小
- -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- CGFloat width = (collectionView.bounds.size.width - ((_count+1) * 20)) / _count;
-
- CGFloat height = width;
-
- return CGSizeMake(width, height);
- }
- //设置每个item之间的间距
- -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
- {
- //return UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)
- return UIEdgeInsetsMake(5, 15, 5, 15);
- }
- //选择item
- -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- {
- UIStoryboard *testStoryboard = [UIStoryboard storyboardWithName:@"Test" bundle:[NSBundle mainBundle]];
-
- OrderFormTableViewController *orderFormController=(OrderFormTableViewController *)[testStoryboard instantiateViewControllerWithIdentifier:@"orderFormController"];
- orderFormController.caller=[[allSearchMenu objectAtIndex:indexPath.row] objectForKey:@"mq_caller"];
- orderFormController.titile=[[allSearchMenu objectAtIndex:indexPath.row] objectForKey:@"mq_title"];
- orderFormController.isHaveCreatList = @"NO";
- orderFormController.is49 = @"NO";
- [self.navigationController pushViewController:orderFormController animated:YES];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|