//
// TypeViewController.m
// BJ
//
// Created by shirenfeng on 16/11/6.
// Copyright © 2016年 com.wsb123. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CustomActivityIndicator.h"
#import "TypeViewController.h"
#import "HttpConnect.h"
#import "FTMacro.h"
#import "UIImageView+WebCache.h"
#import "Utilities.h"
#import "NoNetWorkingView.h"
#import "DBStrore.h"
#import "TagsTableCell.h"
#import "MultilevelMenu.h"
#import "TagsTableViewController.h"
#import "BrandViewController.h"
#import "PicViewController.h"
@interface TypeViewController () @property (strong, nonatomic) UIButton *mLookPicButton; @end @implementation TypeViewController - (void)viewDidLoad00 {
[super viewDidLoad]; NSLog(@"MY TYPEVIEWCONTROLLER"); UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
backItem.title = @"返回";
self.navigationItem.backBarButtonItem = backItem; UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(kScreenWidth - , , kScreenWidth, )];
headView.backgroundColor = [UIColor whiteColor];
headView.layer.masksToBounds = YES;
headView.layer.cornerRadius = ; UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(, , , )];
image.image = [UIImage imageNamed:@"search_k"];
[headView addSubview:image]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image.frame) + , , , headView.frame.size.height)];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor grayColor];
label.font = [UIFont systemFontOfSize:];
label.text = @"搜索商品";
[headView addSubview:label]; UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(, , headView.frame.size.width, headView.frame.size.height)];
[rightButton addTarget:self action:@selector(pushSearchView:) forControlEvents:UIControlEventTouchUpInside];
rightButton.backgroundColor = [UIColor clearColor];
[headView addSubview:rightButton]; self.navigationItem.titleView = headView; self.mTableView = [[UITableView alloc] initWithFrame:CGRectMake(, , kScreenWidth, kScreenHeight) style:UITableViewStylePlain];
self.mTableView.backgroundColor = [UIColor whiteColor];
self.mTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.mTableView.showsVerticalScrollIndicator = YES;
[self.view addSubview:self.mTableView]; self.type1Array=[[NSMutableArray alloc] init];
[self getType ]; }
- (void)viewDidLoad {
[super viewDidLoad]; NSLog(@"MY TYPEVIEWCONTROLLER"); UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
backItem.title = @"返回";
self.navigationItem.backBarButtonItem = backItem; UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(, , kScreenWidth, )];
// headView.backgroundColor = [UIColor grayColor];
headView.layer.masksToBounds = YES; UIView *leftHeadView = [[UIView alloc] initWithFrame:CGRectMake(, , kScreenWidth-, )];
leftHeadView.backgroundColor = [UIColor whiteColor];
leftHeadView.layer.masksToBounds = YES;
leftHeadView.layer.cornerRadius = ; UIView *rightHeadView = [[UIView alloc] initWithFrame:CGRectMake(kScreenWidth-, , , )];
leftHeadView.backgroundColor = [UIColor whiteColor];
leftHeadView.layer.masksToBounds = YES; UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(, , , )];
image.image = [UIImage imageNamed:@"search_k"];
[leftHeadView addSubview:image]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image.frame) + , , , headView.frame.size.height)];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor grayColor];
label.font = [UIFont systemFontOfSize:];
label.text = @"搜索商品";
[leftHeadView addSubview:label]; UIButton *searchButton = [[UIButton alloc] initWithFrame:CGRectMake(, , leftHeadView.frame.size.width, headView.frame.size.height)];
[searchButton addTarget:self action:@selector(pushSearchView:) forControlEvents:UIControlEventTouchUpInside];
searchButton.backgroundColor = [UIColor clearColor];
[leftHeadView addSubview:searchButton]; [headView addSubview:leftHeadView]; UIButton *lookPicButton = [[UIButton alloc] initWithFrame:CGRectMake(, , , headView.frame.size.height)];
[lookPicButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
[lookPicButton setTitle:@"对比(..)" forState:UIControlStateNormal];
// [lookPicButton setTitle:@"对比(..)" forState:UIControlStateHighlighted];
[lookPicButton setTitleColor:self.view.tintColor forState:UIControlStateNormal];
lookPicButton.backgroundColor = [UIColor clearColor];
lookPicButton.titleLabel.font = [UIFont systemFontOfSize: 15.0];
[lookPicButton addTarget:self action:@selector(lookPicBtnClick) forControlEvents:UIControlEventTouchUpInside];
_mLookPicButton=lookPicButton; [rightHeadView addSubview:lookPicButton]; [headView addSubview:rightHeadView]; self.navigationItem.titleView = headView; self.mTableView = [[UITableView alloc] initWithFrame:CGRectMake(, , kScreenWidth, kScreenHeight) style:UITableViewStylePlain];
self.mTableView.backgroundColor = [UIColor whiteColor];
self.mTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.mTableView.showsVerticalScrollIndicator = YES;
[self.view addSubview:self.mTableView]; self.type1Array=[[NSMutableArray alloc] init]; NSLog(@"viewdidload get type");
//[self getType ]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(freshCapPicCount:) name:@"freshCapPicCount" object:nil]; }
- (void)lookPicBtnClick
{
PicViewController *picVC = (PicViewController *)[[UIStoryboard storyboardWithName:@"picview" bundle:nil] instantiateViewControllerWithIdentifier:@"PicViewController"]; [self.navigationController pushViewController:picVC animated:YES]; }
-(void)viewWillAppear:(BOOL)animated
{
//开启定时器
// [scrollView.myTimer setFireDate:[NSDate distantPast]];
NSLog(@"viewWillAppear:%d",[DBStrore sharedDBStore].CapPicArray.count);
[_mLookPicButton setTitle:[NSString stringWithFormat:@"对比(%d)",[DBStrore sharedDBStore].CapPicArray.count] forState: UIControlStateNormal]; if(self.type1Array.count==){
NSLog(@"viewWillAppear get type");
[self getType ];
}
}
-(void) freshCapPicCount:(NSNotification*)notify
{
NSLog(@"type brand view freshCapPicCount:%d",[DBStrore sharedDBStore].CapPicArray.count);
[_mLookPicButton setTitle:[NSString stringWithFormat:@"对比(%d)",[DBStrore sharedDBStore].CapPicArray.count] forState: UIControlStateNormal];
}
-(void)viewDidDisappear:(BOOL)animated
{
//关闭定时器
//[scrollView.myTimer setFireDate:[NSDate distantFuture]];
NSLog(@"viewDidDisappear");
} - (void)timeOut:(id)time
{
[Utilities removeMyGifImageView:self.view];
} /*
-(void)setupMenu000
{
NSMutableArray * lis=[NSMutableArray arrayWithCapacity:0]; * 构建需要数据 2层或者3层数据 (ps 2层也当作3层来处理) NSInteger countMax=20;
for (int i=0; i<countMax; i++) { rightMeun * meun=[[rightMeun alloc] init];
meun.meunName=[NSString stringWithFormat:@"菜单%d",i];
NSMutableArray * sub=[NSMutableArray arrayWithCapacity:0];
for ( int j=0; j <countMax+1; j++) { rightMeun * meun1=[[rightMeun alloc] init];
meun1.meunName=[NSString stringWithFormat:@"菜单%d的头菜单%d",i,j]; [sub addObject:meun1]; //meun.meunNumber=2; NSMutableArray *zList=[NSMutableArray arrayWithCapacity:0];
// if (j%2==0)
{ for ( int z=0; z <countMax+2; z++) { rightMeun * meun2=[[rightMeun alloc] init];
meun2.ID=[NSString stringWithFormat:@"id:%d-%d-%d",i,j,z];
meun2.urlName=@"http://img10.360buyimg.com/n7/jfs/t2182/214/885877100/114709/65627d58/563041eeNa301882b.jpg";
meun2.meunName=[NSString stringWithFormat:@"菜单%d的头菜单%d的第%d个",i,j,z]; [zList addObject:meun2]; }
} meun1.nextArray=zList;
} meun.nextArray=sub;
[lis addObject:meun];
} MultilevelMenu * view=[[MultilevelMenu alloc] initWithFrame:CGRectMake(0, 64, kScreenWidth, kScreenHeight-114) WithData:lis withSelectIndex:^(NSInteger left, NSInteger right,rightMeun* info) { NSLog(@"点击的 left=%d right=%d ID=%@",left,right,info.ID); BrandViewController *brandView = [[BrandViewController alloc] initWithNibName:@"BrandViewController" bundle:nil];
brandView.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:brandView animated:YES]; // [[DBStrore sharedDBStore] showInformationView:7]; }]; // view.leftSelectColor=[UIColor greenColor];
// view.leftSelectBgColor=[UIColor redColor];
view.isRecordLastScroll=YES;
[self.view addSubview:view]; }
*/ -(void)setupMenu
{
NSMutableArray * lis=[NSMutableArray arrayWithCapacity:]; /**
* 构建需要数据 2层或者3层数据 (ps 2层也当作3层来处理)
*/
NSInteger type1count=self.type1Array.count;
for (int i=; i<type1count; i++) {
type1Model *type1=[self.type1Array objectAtIndex:i];
rightMeun * meun=[[rightMeun alloc] init];
// meun.meunName=[NSString stringWithFormat:@"菜单%d %@",i,type1.name];
meun.meunName=[NSString stringWithFormat:@"%@",type1.name];
// NSLog(@"type1name:%@",meun.meunName);
NSMutableArray * sub=[NSMutableArray arrayWithCapacity:];
NSInteger type2count=type1.type2Array.count;
for ( int j=; j <type2count; j++) {
type2Model *type2=[type1.type2Array objectAtIndex:j];
rightMeun * meun1=[[rightMeun alloc] init];
// meun1.meunName=[NSString stringWithFormat:@"菜单%d的头菜单%d %@",i,j,type2.name];
meun1.meunName=[NSString stringWithFormat:@"%@",type2.name];
// NSLog(@"type2name:%@",meun1.meunName);
[sub addObject:meun1]; //meun.meunNumber=2; NSMutableArray *zList=[NSMutableArray arrayWithCapacity:]; NSInteger type3count=type2.type3Array.count;
for ( int z=; z <type3count; z++) {
type3Model *type3=[type2.type3Array objectAtIndex:z];
rightMeun * meun2=[[rightMeun alloc] init];
// meun2.ID=[NSString stringWithFormat:@"id:%d-%d-%d=%d",i,j,z,type3.type3id];
meun2.ID=[NSString stringWithFormat:@"%d",type3.type3id];
meun2.urlName=type3.pic;
// @"http://img10.360buyimg.com/n7/jfs/t2182/214/885877100/114709/65627d58/563041eeNa301882b.jpg";
// meun2.meunName=[NSString stringWithFormat:@"菜单%d的头菜单%d的第%d个",i,j,z];
meun2.meunName=[NSString stringWithFormat:@"%@",type3.name];
// NSLog(@"type3name:%@",meun2.meunName); [zList addObject:meun2]; } if(type3count>)
{
meun1.nextArray=zList;
}
} if(type2count > ){
meun.nextArray=sub;
} [lis addObject:meun];
} MultilevelMenu * view=[[MultilevelMenu alloc] initWithFrame:CGRectMake(, , kScreenWidth, kScreenHeight-) WithData:lis withSelectIndex:^(NSInteger left, NSInteger right,rightMeun* info) { NSLog(@"点击的 left=%d right=%d ID=%@",left,right,info.ID); BrandViewController *brandView = [[BrandViewController alloc] initWithNibName:@"BrandViewController" bundle:nil];
brandView.type3id=[info.ID intValue];
brandView.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:brandView animated:YES]; // [[DBStrore sharedDBStore] showInformationView:7]; }]; // view.leftSelectColor=[UIColor greenColor];
// view.leftSelectBgColor=[UIColor redColor];
view.isRecordLastScroll=YES;
[self.view addSubview:view]; } -(void)getType
{
HttpConnect * connect = [[HttpConnect alloc] init];
connect.delegate = self;
NSMutableDictionary * dic = [NSMutableDictionary dictionary]; [Utilities addMyGifImageView:self];
[self performSelector:@selector(timeOut:) withObject:self afterDelay:]; [connect postRequestForPostValue:dic url:@"gettype.php" requestTag:];
} -(void)postRequestStarted:(AFHTTPRequestOperation*)request manage:(AFHTTPRequestOperationManager*)manage{ NSLog(@"REQ START");
}
-(void)postRequestFinished:(AFHTTPRequestOperation*)request manage:(AFHTTPRequestOperationManager*)manage{ NSLog(@"REQ FINISHED");
[Utilities removeMyGifImageView:self.view];
if(self.type1Array.count>){
[self.type1Array removeAllObjects];
} NSDictionary * dictionary = [NSJSONSerialization JSONObjectWithData:request.responseData options:NSJSONReadingMutableLeaves error:nil ];
NSString * status = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"status"]];
// NSLog(@"status=%@",status);
if([status isEqualToString: @""]){
NSArray *dataArray = [request.responseObject objectForKey:@"data"];
if(dataArray){
for(int i=;i<dataArray.count;i++){
type1Model *type1=[[type1Model alloc] init];
type1.type1id=[[dataArray[i] objectForKey:@"type1id"] intValue];
type1.type=[[dataArray[i] objectForKey:@"type"] intValue];
type1.name=[dataArray[i] objectForKey:@"name"]; NSArray *type2Array = [dataArray[i] objectForKey:@"type2table"];
if(type2Array){
for(int i=;i<type2Array.count;i++){
type2Model *type2=[[type2Model alloc] init];
type2.type2id=[[type2Array[i] objectForKey:@"type2id"] intValue];
type2.name=[type2Array[i] objectForKey:@"name"]; NSArray *type3Array = [type2Array[i] objectForKey:@"type3table"];
if(type3Array){
for(int i=;i<type3Array.count;i++){
type3Model *type3=[[type3Model alloc] init];
type3.type3id=[[type3Array[i] objectForKey:@"type3id"] intValue];
type3.name=[type3Array[i] objectForKey:@"name"];
type3.pic=[type3Array[i] objectForKey:@"pic"];
NSLog(@"type3.pic=%@",type3.pic);
type3.topprice=[[type3Array[i] objectForKey:@"topprice"] intValue];
type3.url=[type3Array[i] objectForKey:@"url"];
[type2.type3Array addObject:type3];
}
}
[type1.type2Array addObject:type2];
}
}
[self.type1Array addObject:type1];
}
[self setupMenu];
} } }
-(void)postRequestFailed:(AFHTTPRequestOperation*)request manage:(AFHTTPRequestOperationManager*)manage{ [Utilities removeMyGifImageView:self.view];
NSLog(@"REQ FAILED");
// [self.view addSubview:[CustomAlertView alertWith:@"0" message:NSLocalizedString(@"error", @"错误")]];
} - (void)pushSearchView:(id)sender
{
TagsTableViewController *tagVC = (TagsTableViewController *)[[UIStoryboard storyboardWithName:@"Search" bundle:nil] instantiateViewControllerWithIdentifier:@"TagsTableViewController"];
//tagVC.is_pushGuideInfoView = NO;
//tagVC.type = 1;
[self.navigationController pushViewController:tagVC animated:YES]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end

加扣群385378208即可下载工程源码

iOS开发总结-类似京东分类,UICollectionView的更多相关文章

  1. iOS开发——UI篇OC篇&UICollectionView详解+实例

    UICollectionView详解+实例 实现步骤: 一.新建两个类 1.继承自UIScrollView的子类,比如HMWaterflowView * 瀑布流显示控件,用来显示所有的瀑布流数据 2. ...

  2. iOS开发中常用的分类方法---UIImage+Category

    在开发中使用分类对原有的系统类进行方法扩展,是增强系统原有类功能的常见做法. /** * 自由拉伸一张图片 * * @param name 图片名字 * @param left 左边开始位置比例 值范 ...

  3. iOS开发学习-类似微信聊天消息中的电话号码点击保存到通讯录中的功能

    类似微信聊天消息中的电话号码点击保存到通讯录中的功能,ABAddress的实现在iOS9中是不能正常使用的,点击完成后,手机会非常的卡,iOS9之后需要使用Contact新提供的方法来实现该功能.快捷 ...

  4. IOS开发之——类似微信摇一摇的功能实现

    首先,一直以为摇一摇的功能实现好高大上,结果百度了.我自己也模仿写了一个demo.主要代码如下: 新建一个项目,名字为AnimationShake. 主要代码: - (void)motionBegan ...

  5. iOS开发之圆角指定 分类: ios技术 2015-05-25 16:26 191人阅读 评论(0) 收藏

    如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架).而若要指定某几个角(小于4)为圆角而别的不变时 ...

  6. iOS 开发中类似上下滚动弹幕实现原理

    #mark ---滚动弹幕 列表中留有7条记录  大于7条时删除并指引表视图向上滑动 - (void)addRowActionWithContent:(NSString *)str { if (sel ...

  7. iOS开发——OC篇&OC高级语法

    iOS开发高级语法之分类,拓展,协议,代码块详解 一:分类 什么是分类Category? 分类就是类的补充和扩展部分 补充和扩展的每个部分就是分类 分类本质上是类的一部分 分类的定义 分类也是以代码的 ...

  8. iOS开发之主题皮肤

    iOS开发之主题皮肤 分类: [iOS]  最近在开发一款[公交应用],里面有个模块涉及到主题设置,这篇文章主要谈一下个人的做法. 大概的步骤如下: (1):整个应用依赖于一个主题管理器,主题管理器根 ...

  9. iOS仿京东分类菜单之UICollectionView内容

    在上<iOS仿京东分类菜单实例实现>已经实现了大部分主体的功能,本文是针对右边集合列表进行修改扩展,使它达到分组的效果,本文涉及到的主要是UICollectionView的知识内容,左边列 ...

随机推荐

  1. Android Camera拍照 压缩

    http://www.linuxidc.com/Linux/2014-12/110924.htm package com.klp.demo_025; import java.io.ByteArrayI ...

  2. git的使用方法总结

    一.创建版本库 $ cd D:   进入d盘 $ cd wamp/www 进入相应目录 $ mkdir test 创建目录 $ git init 把目录变为git可以管理的仓库 二.提交文件到版本库 ...

  3. win7下配置IIS服务器方法

    网站爱好初学者必看的win7系统配置自己的IIS,可以在你自己的电脑上配置网站服务器发不到网上,下面就跟着我的步骤一起做吧100%成功. 步骤方法 1.点击开始-------控制面板这个就是打开的控制 ...

  4. Quartz1.8.5例子(一)

    /* * Copyright 2005 - 2009 Terracotta, Inc. * * Licensed under the Apache License, Version 2.0 (the ...

  5. svn代码统计

    http://chenzhou123520.iteye.com/blog/1436653

  6. oc调用c++接口时 报错 Undefined symbols for architecture i386:

    当在oc中调用c++中的方法时,发现说c++中的方法没定义或是找不到 Undefined symbols for architecture i386: "_desTYData", ...

  7. java or spring +jython +python (Error:python.home,Determine if the following attributes are correct:)

    最近更新 :16年3月10日更 首先你在用JAVA,你需要运行Python,于是你找了Jython,我不介绍什么是Jythyon了 如何在Java中调用Python的方法,一百度一大堆, 如下:是一种 ...

  8. C++必备知识

    新进C++程序员应在一年内完成学习“basic”类别知识点,两年内完成学习“advance”类别知识点,三到四年内完成学习“expert”1.基础(Basic)(1)变量与基本类型:(2)typede ...

  9. Lowest Common Ancestor of a Binary Tree——Leetcode

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...

  10. Unity Chan Advanced

    1. 8X MSAA 2. SMAA 3. ViewSpace Outline 4. Unity Chan Skin 5. Shift Toon Lighting 6. DOF 7. Bloom