//
// 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. 添加标签2 jquery 和JS

    TAG添加标签 做了个方法方便调用 一.JS版本 <!DOCTYPE html> <html lang="en"> <head> <met ...

  2. ZendFramework使用中常见问题

    MVC 代码书写:控制器代码书写:<?phpclass IndexController extends Zend_Controller_Action{ function init() { $th ...

  3. [CSS]float&clear浮动

    CSS float 属性 浮动的框可以向左或向右移动,直到它的外边缘碰到包含框或另一个浮动框的边框为止. 由于浮动框不在文档的普通流中,所以文档的普通流中的块框表现得就像浮动框不存在一样.  可取的值 ...

  4. Dalvik虚拟机进程和线程的创建过程分析

    从前面Dalvik虚拟机的运行过程分析一文可以知道,Dalvik虚拟机除了可以执行Java代码之外,还可以执行Native代码,也就是C/C++函数. 这些C/C++函数在执行的过程中,又可以通过本地 ...

  5. IntelIoT技术笔记Java/Eclipse

    1. 获取最新版本 使用"Team sync perspective",如果想要看到全部工程的差异,选择全部工程,右键-Team-sync with Repository:将会自动 ...

  6. iOS代码实现:创建按钮,绑定按钮事件,读取控件值

    // // main.m // Hello // // Created by lishujun on 14-8-28. // Copyright (c) 2014年 lishujun. All rig ...

  7. 一步一步理解 Java 企业级应用的可扩展性

    摘要:本文主要介绍如何理解 Java 应用的扩展方式以及不同类型的扩展技术和具体技巧,介绍一些有关 Java 企业级应用的一般扩展策略. 老实说,"可扩展性"是个全面且详尽的话题, ...

  8. Eclipse配置Git

    一.Eclipse上安装GIT插件EGit Eclipse的版本eclipse-java-helios-SR2-win32.zip(在Eclipse3.3版本找不到对应的 EGit插件,无法安装) E ...

  9. 《Effective C++》条款14 总是让base class拥有virtual destructor

    有时,一个类想跟踪它有多少个对象存在.一个简单的方法是创建一个静态类成员来统计对象的个数.这个成员被初始化为0,在构造函数里加1,析构函数里减1.(条款m26里说明了如何把这种方法封装起来以便很容易地 ...

  10. Bluetooth LE(低功耗蓝牙) - 第六部分(完)

    在本系列前面的文章中我们已经了解了,在我们从一个TI SensorTag中获取温度和湿度数据之前,我们需要经历的各种步骤.在本系列中的最后一篇文章,我们将完成注册并接收SensorTag的通知,并接收 ...