//
// SearchDocviewcontroller.m
// Patient
//
// Created by gzz on 15/9/21.
// Copyright (c) 2015年 ShangYu. All rights reserved.
//
#import "SearchDocviewcontroller.h"
#import "NearbyViewController.h"
#import "SweepViewController.h"
#import "DocDetailViewController.h"
#import "GZKeyboard.h"
#import "Reachability.h"
#define MARGIN 10
@interface SearchDocviewcontroller ()<UITableViewDelegate,BMKGeoCodeSearchDelegate,BMKGeoCodeSearchDelegate,BMKLocationServiceDelegate,BMKMapViewDelegate,BMKLocationServiceDelegate,BMKMapViewDelegate,UITableViewDataSource,UITextFieldDelegate,GZKeyboardDelegate,UIPickerViewDelegate,UIPickerViewDataSource,UIGestureRecognizerDelegate,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
{
Reachability *hostReach22;
BOOL isNet;//gzz0222
BOOL isbool;
BOOL isComboBoxHide;
BOOL isExpectHospital;
BOOL isIllcase;
BOOL isArea;
int numberDOc;
UIImageView *imagershuju;
UILabel *tiwuxianLab;
BOOL scerocrBol;
int sousuoNum;
//gzz0407 定位标示
BOOL isLoca;
BMKMapView* _mapView;
BMKLocationService* _locService;
BOOL isLocation;
UIButton *firstBtn;//gzz0714
UIButton *secondBtn;
UICollectionView *_collectionViewFirst;
UICollectionView *_collectionViewSecond;
NSMutableArray *shengMm;
NSMutableArray *shiquMm;
BOOL shengKai;
NSString *shengStrr;
NSString *shiquStrr;
}
@property (nonatomic,strong) BMKGeoCodeSearch *geocodesearch;
//服务器上 获取数据
@property (nonatomic,strong) NSMutableArray *disease;
@property (nonatomic,strong) NSMutableArray *searchDocArray;
//搜索医生 参数
@property (nonatomic,copy) NSString *hospitalName;
@property (nonatomic,copy) NSString *realName;
@property (nonatomic,copy) NSString *diseaseUuid;
@property (nonatomic,copy) NSString *provId;
@property (nonatomic,copy) NSString *cityId;
@property (nonatomic,copy) NSString *countyId;
@property (nonatomic,copy) NSString *page;
@property (nonatomic,strong) NSMutableArray *searchplaceArray;
@property(nonatomic,strong)UITextField *textField;
@property(nonatomic,strong)UITableView *tableview;
@property(nonatomic,strong)UIView *Wholeview;
@property(nonatomic,strong)UILabel *illLabel;
@property(nonatomic,strong)UILabel *zoneLabel;
//显示的view
@property(nonatomic,strong)UIView *comboBox;
//病例种类tableview
@property (nonatomic,strong) UITableView *tabComboBox;
//病情的种类
@property (nonatomic,strong) UIButton *illcases;
@property (nonatomic,strong) UIButton *illcasesBtn;
@property (nonatomic,strong) UILabel *labelIll;
//王建自定义的 packagingView
@property(nonatomic,strong) UIView *packagingView;
@property (nonatomic,strong) UIImageView *headImage;
@property (nonatomic,strong) UILabel *labname;
@property (nonatomic,strong) UILabel *labpost;
@property (nonatomic,strong) UILabel *labyiy;
@property (nonatomic,strong) UILabel *zhuanchang;
@property (nonatomic,strong) UILabel *labServer;
//1105 改成联动的 省市区
@property (nonatomic,strong) UIButton *areaDocBtn;
/*===================省市区=======开始=====================*/
@property (nonatomic,strong) NSMutableArray *searchplaceArraDoc;
//数据库 中的值
@property (nonatomic,strong) NSMutableArray *dbProvinceMarrayDOc;
@property (nonatomic,strong) NSMutableArray *dbProvinceNameDoc;
@property (nonatomic,strong) NSMutableArray *dbCityMarrayDoc;
@property (nonatomic,strong) NSMutableArray *dbZoneMarrayDoc;
@property (nonatomic,copy) NSString *proVIdDoc;
@property (nonatomic,copy) NSString *cityIdDoc;
@property (nonatomic,copy) NSString *countryIDoc;
@property (nonatomic,copy) NSString *proDOC1; //省市区 ----转化为ID
@property (nonatomic,copy) NSString *cityDOC1;
@property (nonatomic,copy) NSString *zoneDOC1;
/*===================省市区=======结束====================*/
/*===================uipickerview======开始====================*/
@property (nonatomic,strong) UIPickerView *pickViewDoc;
@property (nonatomic, assign) NSInteger selectedProIndexDOC;
@property(nonatomic,assign)NSInteger selectedCityIndexDOc;
@property(nonatomic,assign)NSInteger selectedZoneIndexDoc;
@property (nonatomic, strong) NSIndexPath *indexPathDoc;
@property (nonatomic,copy) NSString *proStrDoc; //值 展示在 label上
@property(nonatomic,copy)NSString *cityStrDoc;
@property(nonatomic,copy)NSString *zoneStrDoc;
@property (nonatomic, strong) NSArray* provincesDoc;
/*===================uipickerview======结束====================*/
@property (nonatomic,strong) UIImageView *ImageViewbg;
@property(nonatomic,strong) UIView *shangview;
@property (nonatomic,strong) UIButton *addressBTN;
@property (nonatomic,strong) UILabel *addressLLel;
//1209
@property(nonatomic,assign)int proINdex;
@property(nonatomic,assign)int cityINdex;
@property(nonatomic,assign)int zoneINdex;
@property(nonatomic,assign)BOOL isSelectIN;
@property(nonatomic,copy)NSString *PROsheng;
@property(nonatomic,copy)NSString *CITYshi;
@property(nonatomic,copy)NSString *ZONEqu;
//gzz0127
@property(nonatomic,strong)UIWindow *yingziwindow22;
@property(nonatomic,strong)UIView *coverView22;
@property(nonatomic,strong)UIView *showView22;
@property(nonatomic,strong)UIImageView *imagviews22;
@end
static FMDatabase *_dataBase;
@implementation SearchDocviewcontroller
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];// 1
// 监测网络情况gzz0222
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged22:)
name: kReachabilityChangedNotification
object: nil];
hostReach22 = [Reachability reachabilityWithHostName:@"www.google.com"];
[hostReach22 startNotifier];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
//gzz0222
// 监测网络情况
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged22:)
name: kReachabilityChangedNotification
object: nil];
hostReach22 = [Reachability reachabilityWithHostName:@"www.google.com"];
[hostReach22 startNotifier];
//gzz0708
isLocation = NO;
sousuoNum=1;
//数据库操作
NSString*patha=[[NSBundle mainBundle]pathForResource:@"huanzhelas.sqlite" ofType:nil];
_dataBase = [FMDatabase databaseWithPath:patha];
if ([_dataBase open]) {
}
//gzz0407
isLoca = NO;
[self startLocation11];
Dlpontlerexple *dlaer = [Dlpontlerexple shareIndence];
NSString *henam=[NSString stringWithFormat:@"%@",dlaer.logProvIdStr];
NSString *city=[NSString stringWithFormat:@"%@",dlaer.logCityIdStr];
NSString *zone = [NSString stringWithFormat:@"%@",dlaer.logCountyIdStr];
if (henam.length<1||[henam isEqualToString:@"(null)"]||[henam isEqualToString:@"<null>"]) {
henam = @"北京市";
city =@"北京市";
// zone = @"东城区";//gzz0324
zone = @"全部";
isLoca = NO;
}else{
isLoca = YES;
}
shengStrr = henam;
shiquStrr = city;
// _proStrDoc = henam;
// _cityStrDoc = city;
// _zoneStrDoc = zone;
numberDOc=1;
_zoneINdex=-1;
_cityINdex=-1;
_proINdex=-1;
_isSelectIN=YES;
_PROsheng=@"1";
_CITYshi=@"1";
_ZONEqu=@"1";
self.dbProvinceMarrayDOc = [NSMutableArray array];
self.dbProvinceNameDoc = [NSMutableArray array];
self.dbZoneMarrayDoc=[NSMutableArray array];
self.dbCityMarrayDoc=[NSMutableArray array];
self.disease=[NSMutableArray array];
_searchDocArray=[NSMutableArray array];
//gzz0714
shengKai = NO;
shengMm = [NSMutableArray array];
shiquMm = [NSMutableArray array];
[self navBar];
[self maakeUI];
[self diseaseRequestaDOC];//疾病标签列表
[self selectProvinceDOC]; //省市区的开始 -->搜索省
[self DownrefreshDoc];
[self haderwithDoc];
//键盘 退去事件
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
//设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
tapGestureRecognizer.cancelsTouchesInView = NO;
//将触摸事件添加到当前view
[self.view addGestureRecognizer:tapGestureRecognizer];
//gzz0406
if(isLoca){//gzz0714 定位之后自己的搜索
[self searchBtnClick:nil];
}
}
//隐藏键盘 隐藏tableview
-(void)keyboardHide:(UITapGestureRecognizer*)tap{
self.comboBox.hidden=YES;
[_textField resignFirstResponder];
}
#pragma mark 网络监测
- (void)reachabilityChanged22:(NSNotification *)note {
Reachability* curReach = (Reachability*)[note object];
NetworkStatus statNetWork = [curReach currentReachabilityStatus];
if ( statNetWork == NotReachable) {
isNet=NO;
}else{
isNet=YES;
}
}
//navgationBar 1119
-(void)navBar{
self.title=@"找医生";
//字体大小
scerocrBol = NO;
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"gdback3"] originalImage]
style:UIBarButtonItemStylePlain target:self action:@selector(backClickDOC)];
self.navigationItem.leftBarButtonItem=backItem;
//自定义UIBarButtonItem
UIView *view = [[UIView alloc] init];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:view];
Dlpontlerexple *dlaer = [Dlpontlerexple shareIndence];
NSString *city=[NSString stringWithFormat:@"%@",dlaer.logCityIdStr];
if (city.length<1||[city isEqualToString:@"(null)"]) {
city = @"北京市";
}
UILabel *btn1 = [[UILabel alloc]init];//btn1 是label 命名错了 嘿嘿
_addressLLel=btn1;
[view addSubview:btn1];
btn1.height=20;
btn1.width=80;
btn1.text=city;
btn1.textColor=[UIColor whiteColor];
btn1.font=[UIFont systemFontOfSize:14];
btn1.textAlignment=NSTextAlignmentRight;
// [btn1 sizeToFit];
//图片按钮
UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
[view addSubview:btn2];
[btn2 setImage:[UIImage imageNamed:@"map"] forState:UIControlStateNormal];
[btn2 sizeToFit];
//计算各个控件的位置和大小
view.width = btn1.width + btn2.width + 5;
view.height = 44;
btn2.x = CGRectGetMaxX(btn1.frame) + 5;
btn1.y = (view.height - btn1.height) * 0.5;
btn2.y = (view.height - btn2.height) * 0.5;
UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
item3.width = -10;
self.navigationItem.rightBarButtonItems = @[item3,item];
//自定义后退按钮后,手势返回上一级控制器的功能恢复
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
UIImageView *imageCoverBtn=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMinX(btn1.frame), CGRectGetMinY(btn1.frame)-10, view.width+10, 60)];
// imageCoverBtn.backgroundColor=[UIColor redColor];
imageCoverBtn.userInteractionEnabled=YES;
[view addSubview:imageCoverBtn];
//
// UITapGestureRecognizer *tapCover11 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(areaBtnDocClickDoc)];
//设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
// tapCover.cancelsTouchesInView = NO;
//将触摸事件添加到当前view
// [imageCoverBtn addGestureRecognizer:tapCover11];
}
//下拉刷新
- (void)DownrefreshDoc
{
__weak SearchDocviewcontroller *puad = self;
[puad.tableview addHeaderWithCallback:^{
[puad.searchDocArray removeAllObjects];
numberDOc=1;
[puad docListRequest];
[puad.tableview headerEndRefreshing];
}];
}
//上拉加载
- (void)haderwithDoc
{
__weak SearchDocviewcontroller *pudb = self;
[pudb.tableview addFooterWithCallback:^{
numberDOc++;
// [pudb.Newmuwarr removeAllObjects];
[pudb docListRequest];
[pudb.tableview footerEndRefreshing];
}];
}
#pragma mark 医生信息列表请求
-(void)docListRequest{
MCLog(@"ssssccccczzzz======%@....%@",shengStrr,shiquStrr);
//
// NSMutableDictionary *mdict=[[NSMutableDictionary alloc]init];
//
// mdict[@"name"]=self.realName;
// if (self.realName.length>0||self.diseaseUuid.length>0||_proStrDoc.length>0) {
// //gzz 全部
// if (_proStrDoc==nil||_proStrDoc.length==0) {
// mdict[@"provId"]=@"";
// }else{
// mdict[@"provId"] =[self convertDOC:_proStrDoc];
// }
//
// //gzz0323
// if ([_proStrDoc isEqualToString:_cityStrDoc]) {//这说明是定位的 省和市的名字一样
// if (_cityStrDoc==nil||_cityStrDoc.length==0) {
// mdict[@"cityId"]=@"";
// }else{
// mdict[@"cityId"]=@"";
// }
// mdict[@"countyId"]=@"";
//
// }else{
//
//
// if (_cityStrDoc==nil||_cityStrDoc.length==0||[_cityStrDoc isEqualToString:@"全部"]) {
// mdict[@"cityId"]=@"";
// }else{
// mdict[@"cityId"]=[self convertcityDOC:_cityStrDoc];
// }
//
//
// if (_zoneStrDoc==nil||_zoneStrDoc.length==0||[_zoneStrDoc isEqualToString:@"全部"]) {
// mdict[@"countyId"]=@"";
// }else{
// mdict[@"countyId"]=[self convertzoneNameDoc:_zoneStrDoc];
// }
//
//
// }
// //
//
//
//
//
// [MBProgressHUD showHUDAddedTo:self.view animated:YES];
// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];//gzz0617af
// manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json", nil];
// manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//
//
// NSString *str = [NSString stringWithFormat:@"%@searchExpertByName",Public_URL];
// NSString *ouble=[NSString stringWithFormat:@"%d",numberDOc];
// mdict[@"page"]=ouble;
// mdict[@"diseaseUuid"]=self.diseaseUuid;
//
NSMutableDictionary *mdict=[[NSMutableDictionary alloc]init];
mdict[@"name"]=self.realName;
if (self.realName.length>0||shengStrr.length>0) {
//gzz 全部
if (shengStrr==nil||shengStrr.length==0) {
mdict[@"provId"]=@"";
}else{
mdict[@"provId"] =[self convertDOC:shengStrr];
}
//gzz0323
if ([shengStrr isEqualToString:shiquStrr]) {//这说明是定位的 省和市的名字一样
if (shiquStrr==nil||shiquStrr.length==0) {
mdict[@"cityId"]=@"";
}else{
mdict[@"cityId"]=@"";
}
mdict[@"countyId"]=@"";
}
else{
if (shiquStrr==nil||shiquStrr.length==0||[shiquStrr isEqualToString:@"全部"]) {
mdict[@"cityId"]=@"";
}else{
mdict[@"cityId"]=[self convertcityDOC:shiquStrr];
}
mdict[@"countyId"]=@"";
}
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];//gzz0617af
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json", nil];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *str = [NSString stringWithFormat:@"%@searchExpertByName",Public_URL];
NSString *ouble=[NSString stringWithFormat:@"%d",numberDOc];
mdict[@"page"]=ouble;
// mdict[@"diseaseUuid"] = self.diseaseUuid;
mdict[@"diseaseUuid"] = @"";
MCLog(@"=====搜索时传递的数据 ==%@",mdict);
MCLog(@"=====搜索时传递的数据 ==%@",mdict);
[manager POST: str parameters:mdict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
NSString *struui = [NSString stringWithFormat:@"%@",dic[@"code"]];
if ([struui isEqualToString:@"1"]) {
// if (sousuoNum==2) {
//
// }
[_searchDocArray addObjectsFromArray:dic[@"data"]];
}
else{
if ([dic[@"message"] isEqualToString:@"未查询到记录"]) {
[self showHint:@"没有更多数据了"];
}else {
// if (isLocation) {
[self showHint:dic[@"message"]];
// }
}
}
if (_searchDocArray.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
}else{
imagershuju.hidden = NO;
tiwuxianLab.hidden = NO;
}
// MCLog(@"_searchDocArray====%@",_searchDocArray);
[self.tableview reloadData];
// MCLog(@"--医生列表--%@----",dic);
[MBProgressHUD hideHUDForView:self.view animated:YES];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
MCLog(@"医生列表___请求失败!111");
[self.tableview reloadData];
if (_searchDocArray.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
}else{
imagershuju.hidden = NO;
tiwuxianLab.hidden = NO;
}
[self showHint:@"请求数据失败"];//gzz0222 gzz0708
// NSString *errcode=[NSString stringWithFormat:@"%@",error.localizedDescription];
// [self showHint:errcode];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
else{
[self alretview:@"请选择搜索条件"];
}
}
#pragma mark 肝胆病标签请求
-(void)diseaseRequestaDOC{
//获取肝胆病标签 disease
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];//gzz0617af
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json", nil];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *str = [NSString stringWithFormat:@"%@disease",Public_URL];
[manager POST: str parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSDictionary *diseaseDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
NSString *codeee=[NSString stringWithFormat:@"%@",diseaseDic[@"code"]];
if ([codeee isEqualToString:@"1"]) {
NSMutableArray *arrry=[NSMutableArray arrayWithArray:diseaseDic[@"data"]];
NSDictionary *name=[NSDictionary dictionaryWithObject:@"病类" forKey:@"name"];
NSArray *add1=[NSArray arrayWithObjects:name ,nil];
NSMutableArray *arrM = [[NSMutableArray alloc] init];
[arrM addObjectsFromArray:add1];
[arrM addObjectsFromArray:arrry];
self.disease = arrM;
//
if (self.disease.count>0) {//gzz0201
[self.tabComboBox reloadData];
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
}else {
_yingziwindow22.hidden=YES;//gzz0201
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
MCLog(@"获取肝胆病标签_失败!111");
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
/**
* 1119
*
* @return 主页面
*/
-(void)maakeUI{
UIImageView *imageVi=[[UIImageView alloc]initWithFrame:CGRectMake(0,64,SCREEN_WIDTH, SCREEN_HEIGHT-64)];
imageVi.image=[UIImage imageNamed:@"jianbian5"];
imageVi.userInteractionEnabled=YES;
_ImageViewbg=imageVi;
[self.view addSubview:imageVi];
//gzz0714
UIView *topView = [[UIView alloc]init];
topView.frame = CGRectMake(15, 10, SCREENW-30, 40);
topView.backgroundColor = WHITECOLORS;
[imageVi addSubview:topView];
UIButton *firstB=[[UIButton alloc]initWithFrame:CGRectMake(10, 5,topView.width/2-20, 30)];
firstBtn = firstB;
// firstBtn.backgroundColor = [UIColor lightGrayColor];
firstBtn.backgroundColor = RGB(220, 220, 220);[UIColor lightGrayColor];
[topView addSubview:firstB];
[firstB setTitle:@"选择省份" forState:0];
[firstB setTitleColor:WHITECOLORS forState:0];
//点击按钮
[firstB addTarget:self action:@selector(firstBtnClick) forControlEvents:UIControlEventTouchUpInside];
UIView *shuLine=[[UIView alloc]initWithFrame:CGRectMake(topView.width/2,5, 1, 30)] ;
shuLine.backgroundColor = RGB(60, 199, 192);
//RGB(188, 188, 188);//RGB(60, 199, 192);
[topView addSubview:shuLine];
UIButton *secondB=[[UIButton alloc]initWithFrame:CGRectMake(10+topView.width/2+1, 5,topView.width/2-20, 30)];
secondBtn = secondB;
[secondB setTitle:@"选择市区" forState:0];
[secondB setTitleColor:WHITECOLORS forState:0];
secondB.backgroundColor = RGB(220, 220, 220);//[UIColor lightGrayColor];
[topView addSubview:secondB];
//点击按钮
[secondB addTarget:self action:@selector(secondBtnClick) forControlEvents:UIControlEventTouchUpInside];
CGFloat topViewY = CGRectGetMaxY(topView.frame)+10;
UIView *views=[[UIView alloc]initWithFrame:CGRectMake(15,topViewY,SCREEN_WIDTH-30,45)];
// UIView *views=[[UIView alloc]initWithFrame:CGRectMake(15, 15, SCREEN_WIDTH-30,45)];
_shangview=views;
views.backgroundColor=[UIColor whiteColor];
views.layer.cornerRadius=5;
views.layer.masksToBounds=YES;
[imageVi addSubview:views];
UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(15,7.5,views.width-15-45,30)];
// text.backgroundColor=[UIColor purpleColor];//gzz0714
self.textField=text;
text.placeholder = @"搜索专家/医院";
text.font=[UIFont systemFontOfSize:14];
text.textColor = [UIColor blackColor];
text.textAlignment = NSTextAlignmentLeft;
text.delegate=self;
[views addSubview:text];
UIButton *searchBtn=[UIButton buttonWithType:UIButtonTypeCustom];
// searchBtn.backgroundColor=[UIColor blueColor];//gzz0714
[searchBtn setBackgroundImage:[UIImage imageNamed:@"fangdajing"] forState:UIControlStateNormal];
CGFloat btnX=CGRectGetMaxX(text.frame)+10;
searchBtn.frame=CGRectMake(btnX, views.width-35,20,20);
searchBtn.centerY=text.centerY;
[views addSubview:searchBtn];
CGFloat imageCoverX=searchBtn.x-10;
UIImageView *imageCoverBtn=[[UIImageView alloc]initWithFrame:CGRectMake(imageCoverX, 0, 50, 50)];
// imageCoverBtn.backgroundColor=[UIColor redColor];
imageCoverBtn.userInteractionEnabled=YES;
[views addSubview:imageCoverBtn];
UITapGestureRecognizer *tapCover11 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(searchBtnClick:)];
[imageCoverBtn addGestureRecognizer:tapCover11];
[self illcaseView];
}
#pragma mark firstBtnClickgzz0714
-(void)firstBtnClick{
MCLog(@"左边的按钮");
[self.view endEditing:YES];
//gzz0222 没有网络的情况下 不让显示病类列表
if (isNet) {
//gzz0127
//获取keyWindow
UIWindow *window = [UIApplication sharedApplication].keyWindow;
_yingziwindow22=window;
//1 创建遮盖的view
UIView *view11 = [[UIView alloc] init];
self.coverView22 = view11;
//把遮盖的view添加到window上
[window addSubview:view11];
window.userInteractionEnabled=YES;
//让遮盖view的大小和屏幕大小一样。并从0,0开始显示
view11.frame = [UIScreen mainScreen].bounds; //self.view.bounds; //
view11.backgroundColor = [UIColor blackColor];
view11.alpha = 0.4;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesturedDetected11:)]; // 手势类型随你喜欢。
tapGesture.delegate = self;
//设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
tapGesture.cancelsTouchesInView = NO;
[view11 addGestureRecognizer:tapGesture];
UIView *view=[[UIView alloc]init];
self.comboBox=view;
CGFloat ComboBoxX=10;
CGFloat ComboBoxY=(SCREENH-SCREENW)/2;
CGFloat ComboBoxW=SCREENW-20;
CGFloat ComboBoxH=SCREENW-20;
view.frame=CGRectMake(ComboBoxX, ComboBoxY, ComboBoxW, ComboBoxH);
view.center=window.center;
[window addSubview:view];
view.backgroundColor = RGB(188, 188, 188);//[UIColor redColor];//gzz0714
// view.backgroundColor = [UIColor clearColor];//gzz0714
UICollectionViewFlowLayout *flowLayOut = [[UICollectionViewFlowLayout alloc]init];
flowLayOut.minimumInteritemSpacing = 1;
flowLayOut.minimumLineSpacing = 10; //上下的间距 可以设置0看下效果
_collectionViewFirst = [[UICollectionView alloc]initWithFrame:CGRectMake (5, 5,view.width-10,view.height-10) collectionViewLayout:flowLayOut];
_collectionViewFirst.dataSource = self;
_collectionViewFirst.delegate = self;
_collectionViewFirst.backgroundColor = [UIColor whiteColor];
[view addSubview:_collectionViewFirst];
[_collectionViewFirst registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellCollingingSearch"];
self.showView22=view;
self.showView22.userInteractionEnabled=YES;
}else{
[self showHint:@"暂无网络,请检查网络设置!"];
}
}
#pragma mark secondBtnClickgzz0714
-(void)secondBtnClick{
MCLog(@"you边的按钮");
[self.view endEditing:YES];
//gzz0222 没有网络的情况下 不让显示病类列表
if (isNet) {
if (shengKai) {
//gzz0127
//获取keyWindow
UIWindow *window = [UIApplication sharedApplication].keyWindow;
_yingziwindow22=window;
//1 创建遮盖的view
UIView *view11 = [[UIView alloc] init];
self.coverView22 = view11;
//把遮盖的view添加到window上
[window addSubview:view11];
window.userInteractionEnabled=YES;
//让遮盖view的大小和屏幕大小一样。并从0,0开始显示
view11.frame = [UIScreen mainScreen].bounds; //self.view.bounds; //
view11.backgroundColor = [UIColor blackColor];
view11.alpha = 0.4;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesturedDetected11:)]; // 手势类型随你喜欢。
tapGesture.delegate = self;
//设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
tapGesture.cancelsTouchesInView = NO;
[view11 addGestureRecognizer:tapGesture];
UIView *view=[[UIView alloc]init];
self.comboBox=view;
CGFloat ComboBoxX=10;
CGFloat ComboBoxY=(SCREENH-SCREENW)/2;
CGFloat ComboBoxW=SCREENW-20;
CGFloat ComboBoxH=SCREENW-20;
view.frame=CGRectMake(ComboBoxX, ComboBoxY, ComboBoxW, ComboBoxH);
view.center=window.center;
[window addSubview:view];
// view.backgroundColor = [UIColor redColor];//gzz0714
view.backgroundColor = RGB(188, 188, 188);//gzz0714
UICollectionViewFlowLayout *flowLayOut = [[UICollectionViewFlowLayout alloc]init];
flowLayOut.minimumInteritemSpacing = 1;
flowLayOut.minimumLineSpacing = 10; //上下的间距 可以设置0看下效果
// _collectionViewSecond = [[UICollectionView alloc]initWithFrame:CGRectMake (10, 10,view.width-20,view.height-20) collectionViewLayout:flowLayOut];
_collectionViewSecond = [[UICollectionView alloc]initWithFrame:CGRectMake (5, 5,view.width-10,view.height-10) collectionViewLayout:flowLayOut];
_collectionViewSecond.dataSource = self;
_collectionViewSecond.delegate = self;
_collectionViewSecond.backgroundColor = [UIColor whiteColor];
[view addSubview:_collectionViewSecond];
[_collectionViewSecond registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellCollingingSearch22"];
self.showView22=view;
self.showView22.userInteractionEnabled=YES;
NSString *stre = [firstBtn currentTitle];
[self selectCityDOC:stre];
}
// return self.dbCityMarrayDoc[row]
}else{
// [self showHint:@"暂无网络,请检查网络设置!"];
}
}
//病例种类 button
-(void)illcaseBtnClick{
[self.view endEditing:YES];
//gzz0222 没有网络的情况下 不让显示病类列表
if (isNet) {
//gzz0127
//获取keyWindow
UIWindow *window = [UIApplication sharedApplication].keyWindow;
_yingziwindow22=window;
//1 创建遮盖的view
UIView *view11 = [[UIView alloc] init];
self.coverView22 = view11;
//把遮盖的view添加到window上
[window addSubview:view11];
window.userInteractionEnabled=YES;
//让遮盖view的大小和屏幕大小一样。并从0,0开始显示
view11.frame = [UIScreen mainScreen].bounds; //self.view.bounds; //
view11.backgroundColor = [UIColor blackColor];
view11.alpha = 0.4;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesturedDetected11:)]; // 手势类型随你喜欢。
tapGesture.delegate = self;
//设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
tapGesture.cancelsTouchesInView = NO;
[view11 addGestureRecognizer:tapGesture];
UIView *view=[[UIView alloc]init];
self.comboBox=view;
CGFloat ComboBoxX=15;
CGFloat ComboBoxY=15;
CGFloat ComboBoxW=SCREENW*0.5;
CGFloat ComboBoxH=SCREENH-ComboBoxY;
view.frame=CGRectMake(ComboBoxX, ComboBoxY, ComboBoxW, ComboBoxH);
view.centerX=window.centerX;
[window addSubview:view];
//向combobox中添加tableview
_tabComboBox=[[UITableView alloc]init];
_tabComboBox.delegate=self;
_tabComboBox.dataSource=self;
_tabComboBox.frame=CGRectMake(0, 0,ComboBoxW, ComboBoxH);
_tabComboBox.tableFooterView=[[UIView alloc]init];
[self.comboBox addSubview:_tabComboBox];
[window addSubview:view];
self.showView22=view;
self.showView22.userInteractionEnabled=YES;
}else{
[self showHint:@"暂无网络,请检查网络设置!"];
}
}
//病例种类 view
-(void)illcaseView{
//tableview 医生简介
CGFloat tableviewX=0;
CGFloat tableviewY=CGRectGetMaxY(_shangview.frame)+MARGIN*1.5;
CGFloat tableviewW=SCREENW;
CGFloat tableviewH=SCREENH-tableviewY-64;
UITableView *tableView=[[UITableView alloc] initWithFrame:CGRectMake(tableviewX, tableviewY, tableviewW, tableviewH)];
self.tableview=tableView;
self.tableview.dataSource=self;
self.tableview.delegate=self;
self.tableview.tableFooterView = [[UIView alloc]init];
[_ImageViewbg addSubview:self.tableview];
// [self.view addSubview:self.tableview];
imagershuju = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-ImagerWuWidth/2, SCREEN_HEIGHT/2-ImagerWuheight/2, ImagerWuWidth, ImagerWuheight)];
imagershuju.image = [UIImage imageNamed:@"zanwushuju1"];
[self.view addSubview:imagershuju];
tiwuxianLab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-TishiLabwidth/2, CGRectGetMaxY(imagershuju.frame), TishiLabwidth, 30)];
tiwuxianLab.text = @"该地区暂无平台医生";
tiwuxianLab.textAlignment = YES;
tiwuxianLab.textColor = RGB(188, 188, 188);
// tiwuxianLab.hidden = YES;
tiwuxianLab.font = SYSTEMFONT(TishiLabFont);
[self.view addSubview:tiwuxianLab];
// UIview 点击时里面加载的时tableview
UIView *ComboBox=[[UIView alloc]init];
self.comboBox=ComboBox;
CGFloat ComboBoxX=15;
CGFloat ComboBoxY=CGRectGetMaxY(self.shangview.frame)+MARGIN*0.5;
CGFloat ComboBoxW=SCREENW*0.4;
CGFloat ComboBoxH=SCREENH-ComboBoxY-64;
ComboBox.frame=CGRectMake(ComboBoxX, ComboBoxY, ComboBoxW, ComboBoxH);
// ComboBox.backgroundColor=[UIColor yellowColor];
ComboBox.hidden=YES;
[_ImageViewbg addSubview:ComboBox];
// [self.view addSubview:ComboBox];
}
- (void)tapGesturedDetected11:(UITapGestureRecognizer *)recognizer
{ MCLog(@"点到我了 anniu");
[UIView animateWithDuration:0.2 animations:^{
self.showView22.hidden=YES;
self.coverView22.alpha = 0;
} completion:^(BOOL finished) {
[self.coverView22 removeFromSuperview];
self.coverView22=nil;
}];
}
//返回上一级 pop
-(void)backClickDOC{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma UITextfield delegate
- (void)textFieldDidBeginEditing:(UITextField *)textField{
self.comboBox.hidden=YES;
[self.textField becomeFirstResponder];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self.textField resignFirstResponder];
return YES;
}
#pragma tableview su数据源 代理
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView==_tabComboBox){
return 40;
}else{
return 90;//专家简介长度
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (tableView==_tabComboBox) {
return self.disease.count;//病情种类下拉列表
}else{
return _searchDocArray.count; //1105
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView==_tabComboBox) {
//病情种类下来列表
static NSString *illcell=@"illcell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:illcell];
if (!cell) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:illcell];
}
if (self.disease.count>1) {
//gzz0220
// NSDictionary *dicc=[self clearErrorData:[self.disease objectAtIndex:indexPath.row]];
NSDictionary *dicc=[DicRemove clearErrorDataZanwu:[self.disease objectAtIndex:indexPath.row]];//gzz0406
NSString *textt=[dicc objectForKey:@"name"];
cell.textLabel.text=textt;
cell.textLabel.textAlignment=NSTextAlignmentCenter;
}
return cell;
}else {
//专家简介长度
static NSString *cellIn=@"cellIN";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIn ];
if (!cell) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIn];
}
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (_searchDocArray.count>0) {
[cell.contentView addSubview:[self CellFview11ss:(int)indexPath.row]];
}
return cell;
}
}
//1119 自定义cell中的内容
-(UIView *)CellFview11ss:(int)ceellsends{
// NSDictionary *dicerCEll = [self clearErrorData:_searchDocArray[ceellsends]];
NSDictionary *dicerCEll = [DicRemove clearErrorDataZanwu:_searchDocArray[ceellsends]];//gzz0406
UIView *packagingView11 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 90)];
self.packagingView=packagingView11;
//头像
_heaadView=[[UIImageView alloc]initWithFrame:CGRectMake(17.5, 15, 60, 60)];
NSString *photo=[dicerCEll objectForKey:@"photo"];
NSString *imagename=[NSString stringWithFormat:@"%@%@",ImageUrl,photo];
[_heaadView sd_setImageWithURL:[NSURL URLWithString:imagename] placeholderImage:[UIImage imageNamed:@"huisetouxiangfu"]];
//
_heaadView.layer.cornerRadius=30;
_heaadView.layer.masksToBounds=YES;
[packagingView11 addSubview:_heaadView];
//姓名
NSString *realName=[dicerCEll objectForKey:@"realName"];
// self.nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_heaadView.frame)+12,15,80,17)];//gzz0329
self.nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_heaadView.frame)+12,15,SCREEN_WIDTH-174.5+80,17)];//gzz0329
// _nameLabel.backgroundColor=[UIColor redColor];
self.nameLabel.textAlignment=NSTextAlignmentLeft;
self.nameLabel.font=[UIFont systemFontOfSize:14];
self.nameLabel.text=realName;
// [self.nameLabel sizeToFit];
[packagingView11 addSubview:self.nameLabel];
//头衔
NSString *positionName=[dicerCEll objectForKey:@"positionName"];
self.touxianLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_heaadView.frame)+12, CGRectGetMaxY(_nameLabel.frame)+10, 120, 15)];
_touxianLabel.font=[UIFont systemFontOfSize:12];
_touxianLabel.textColor=[UIColor grayColor];
_touxianLabel.text=positionName;
[_touxianLabel sizeToFit];
// _touxianLabel.backgroundColor=[UIColor yellowColor];//gzz0323
[packagingView11 addSubview:_touxianLabel];
//擅长 gzz0323
NSString *specialities=[dicerCEll objectForKey:@"officeName"];
_goodatLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_touxianLabel.frame)+12, CGRectGetMaxY( _nameLabel.frame)+10, 120, 15)];
_goodatLabel.font=[UIFont systemFontOfSize:12];
_goodatLabel.textColor=[UIColor grayColor];
_goodatLabel.text=specialities;
// _goodatLabel.centerY=_touxianLabel.centerY;
[_goodatLabel sizeToFit];
// _goodatLabel.backgroundColor=[UIColor redColor];
[packagingView11 addSubview:_goodatLabel];
//地址
NSString *hospitalName=[dicerCEll objectForKey:@"hospitalName"];
_addressLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_heaadView.frame)+12, CGRectGetMaxY( _touxianLabel.frame)+10, 120, 15)];
_addressLabel.font=[UIFont systemFontOfSize:12];
_addressLabel.textColor=[UIColor grayColor];
_addressLabel.text=hospitalName;
[_addressLabel sizeToFit];
// _addressLabel.backgroundColor=[UIColor blueColor];//gzz0323
[packagingView11 addSubview:_addressLabel];
//擅长 gzz0323
// NSString *specialities=[dicerCEll objectForKey:@"officeName"];
// _goodatLabel=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_addressLabel.frame)+12, CGRectGetMaxY( _addressLabel.frame)+10, 120, 15)];
// _goodatLabel.font=[UIFont systemFontOfSize:12];
// _goodatLabel.textColor=[UIColor grayColor];
// _goodatLabel.text=specialities;
// _goodatLabel.centerY=_addressLabel.centerY;
[_goodatLabel sizeToFit];
_goodatLabel.backgroundColor=[UIColor blueColor];
// [packagingView11 addSubview:_goodatLabel];
/*
"callDisable": "Y", Y禁用电话咨询 N启用电话咨询
"monthDisable": "N",
"clinicDisable": "N",
*/
NSString *strcall1 = [NSString stringWithFormat:@"%@",[dicerCEll objectForKey:@"callIsEnable"]];//gzz0311
NSString *strcall = [NSString stringWithFormat:@"%@",[dicerCEll objectForKey:@"callDisable"]];//gzz0311
UIImageView *imagecall = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-80, 15, 15, 15)];
imagecall.hidden=YES;//gzz0329dev
if ([strcall isEqualToString:@"N"]) {
if ([strcall1 isEqualToString:@"1"]) {
imagecall.image = [UIImage imageNamed:@"callliang"];
}else{
imagecall.image = [UIImage imageNamed:@"doccall"];
}
}else{
imagecall.image = [UIImage imageNamed:@"doccall"];
}
[packagingView11 addSubview:imagecall];
NSString *strclicer1 = [NSString stringWithFormat:@"%@",[dicerCEll objectForKey:@"clinicIsEnable"]];
NSString *strclicer = [NSString stringWithFormat:@"%@",[dicerCEll objectForKey:@"clinicDisable"]];
UIImageView *imageclicer = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imagecall.frame)+10, 15, 12, 15)];
imageclicer.hidden=YES;
if ([strclicer isEqualToString:@"N"]) {
if ([strclicer1 isEqualToString:@"1"]) {
imageclicer.image = [UIImage imageNamed:@"xiaorenliang"];
}else{
imageclicer.image = [UIImage imageNamed:@"xiaoren"];
}
}else{
imageclicer.image = [UIImage imageNamed:@"xiaoren"];
}
[packagingView11 addSubview:imageclicer];
NSString *strmonter = [NSString stringWithFormat:@"%@",[dicerCEll objectForKey:@"monthDisable"]];
NSString *strmonter1 = [NSString stringWithFormat:@"%@",[dicerCEll objectForKey:@"monthIsEnable"]];
UIImageView *imagemonter = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imageclicer.frame)+10, 15, 15, 15)];
imagemonter.hidden=YES;
if ([strmonter isEqualToString:@"N"]) {
if ([strmonter1 isEqualToString:@"1"]) {
imagemonter.image = [UIImage imageNamed:@"vliang"];
}else{
imagemonter.image = [UIImage imageNamed:@"vgarner"];
}
}else{
imagemonter.image = [UIImage imageNamed:@"vgarner"];
}
[packagingView11 addSubview:imagemonter];
return packagingView11;
}
//tabelview的代理 可以获得选中view的值
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.view endEditing:YES];
if(tableView==_tabComboBox){
UITableViewCell *comboxcell = [tableView cellForRowAtIndexPath:indexPath];
if (self.disease.count>1) {
[self.illcases setTitle:comboxcell.textLabel.text forState:0];
self.diseaseUuid=[[self.disease objectAtIndex:indexPath.row] objectForKey:@"uuid"];
MCLog(@"=选择的疾病名称===%@",[[self.disease objectAtIndex:indexPath.row] objectForKey:@"name"]);
_labelIll.text=comboxcell.textLabel.text;
[UIView animateWithDuration:0.2 animations:^{
self.showView22.hidden=YES;
self.coverView22.alpha = 0;
} completion:^(BOOL finished) {
[self.coverView22 removeFromSuperview];
self.coverView22=nil;
}];
}
}
else{
if (_searchDocArray.count>0) {
DocDetailViewController *docD=[[DocDetailViewController alloc]init];
docD.strDocuuid = [_searchDocArray[indexPath.row] objectForKey:@"uuid"];
[self.navigationController pushViewController:docD animated:YES];
}
}
self.comboBox.hidden=YES;
[self.view endEditing:YES];
}
//电话点击
-(void)callClickk:(UIButton *)btn{
btn.selected = !btn.selected;
MCLog(@"电话点击");
}
//小人头点击
-(void)xiaorentouClickk:(UIButton *)btn{
btn.selected = !btn.selected;
MCLog(@"小人头点击");
}
//V字母点击
-(void)VClickk:(UIButton *)btn{
btn.selected = !btn.selected;
MCLog(@"V字母点击");
}
//头像的点击
-(void)imageBUTTON
{
MCLog(@"z专家头像点击 =----searchDoc 中");
}
#pragma mark 搜索的点击事件
-(void)searchBtnClick:(NSString *)str{
self.comboBox.hidden=YES;
[_searchDocArray removeAllObjects];
//在这里判断下 模糊查询下 if
self.realName=self.textField.text;
MCLog(@"==搜索===name====%@",self.realName);
numberDOc=1;//gzz0323 每次搜索时 都要重新变成1
sousuoNum=2;
[self docListRequest];//专家列表信息
[self.view endEditing:YES];
}
#pragma mark 地区按钮
//地区按键
-(void)areaBtnDocClickDoc{
MCLog(@"地址按钮");
Dlpontlerexple *dlaer = [Dlpontlerexple shareIndence];
NSString *henam=[NSString stringWithFormat:@"%@",dlaer.logProvIdStr];
NSString *city=[NSString stringWithFormat:@"%@",dlaer.logCityIdStr];
NSString *zone = [NSString stringWithFormat:@"%@",dlaer.logCountyIdStr];
if (henam.length<1||[henam isEqualToString:@"(null)"]) {
henam = @"北京市";
city =@"北京市";
// zone = @"东城区";//gzz0325
zone = @"全部";
}
_cityStrDoc=@"";
_zoneStrDoc=@"";
_PROsheng = henam;
if ([_PROsheng isEqualToString:@"1"]) {
_isSelectIN=NO;
}
if (scerocrBol==NO) {
scerocrBol = YES;
UITextField *txt11= [UITextField new];
//生成文本框,并且让文本框成为第一响应者
[self.view addSubview:txt11];
//设置键盘的工具栏
GZKeyboard *tool11 = [GZKeyboard keyboardTool];
tool11.delegate = self;
txt11.inputAccessoryView = tool11;
CGFloat screenH=[UIScreen mainScreen].bounds.size.height;
UIPickerView *pickerview=[[UIPickerView alloc]init];
self.pickViewDoc=pickerview;
pickerview.dataSource=self;
pickerview.delegate=self;
//设置居中显示
CGFloat pvX=pickerview.frame.origin.x;
CGFloat pvY=(screenH-pickerview.frame.size.height)-60;
CGFloat pvH=pickerview.bounds.size.height;
CGFloat pvW=pickerview.bounds.size.width;
pickerview.frame=CGRectMake(pvX, pvY, pvW, pvH);
pickerview.backgroundColor=[UIColor whiteColor];
//把弹出键盘改成datePicker
txt11.inputView = pickerview;
//让文本框成为第一响应者,此处之前 应该先设置inputView
[txt11 becomeFirstResponder];
if ([henam isEqualToString:city]) {//gzz0325两级的
//gzz0324
for (int i=0; i<self.dbProvinceNameDoc.count; i++) {
if ([henam isEqualToString:self.dbProvinceNameDoc[i]]) {
_proINdex=i;
}
}
NSMutableArray *cityMarr=[NSMutableArray array];
[self selectCityDOC:henam];
cityMarr=_dbCityMarrayDoc;
for (int i=0; i<cityMarr.count; i++) {
if ([zone isEqualToString:cityMarr[i]]) {
_cityINdex=i;
}
}
if (_proINdex!=-1) {
[pickerview selectRow:_proINdex inComponent:0 animated:NO];
if (_cityINdex!=-1) {
// [pickerview selectRow:_cityINdex inComponent:1 animated:NO];//gzz0325
}
}
_proStrDoc=henam;
_cityStrDoc=zone;
_isSelectIN=YES;
// for (int i=0; i<self.dbProvinceNameDoc.count; i++) {
// if ([henam isEqualToString:self.dbProvinceNameDoc[i]]) {
// _proINdex=i;
// }
// }
//
// NSMutableArray *cityMarr=[NSMutableArray array];
// [self selectCityDOC:henam];
// cityMarr=_dbCityMarrayDoc;
// for (int i=0; i<cityMarr.count; i++) {
// if ([zone isEqualToString:cityMarr[i]]) {
// _cityINdex=i;
// }
// }
//
// if (_proINdex!=-1) {
// [pickerview selectRow:_proINdex inComponent:0 animated:NO];
// if (_cityINdex!=-1) {
// [pickerview selectRow:_cityINdex inComponent:1 animated:NO];
// }
// }
// _proStrDoc=henam;
// _cityStrDoc=zone;
// _isSelectIN=YES;
}else{//三级的
for (int i=0; i<self.dbProvinceNameDoc.count; i++) {
if ([henam isEqualToString:self.dbProvinceNameDoc[i]]) {
_proINdex=i;
}
}
NSMutableArray *cityMarr=[NSMutableArray array];
[self selectCityDOC:henam];
cityMarr=_dbCityMarrayDoc;
for (int i=0; i<cityMarr.count; i++) {
if ([city isEqualToString:cityMarr[i]]) {
_cityINdex=i;
}
}
NSMutableArray *zoneMarr=[NSMutableArray array];
[self selectZoneDOC:city];
zoneMarr=_dbZoneMarrayDoc;
MCLog(@"zoneMarr==%@",zoneMarr);
for (int i=0; i<zoneMarr.count; i++) {
if ([zone isEqualToString:zoneMarr[i]]) {
// _zoneINdex=i;
MCLog(@"zone index %zd",_zoneINdex);
}
}
if (_proINdex!=-1) {
[pickerview selectRow:_proINdex inComponent:0 animated:NO];
if (_cityINdex!=-1) {
[pickerview selectRow:_cityINdex inComponent:1 animated:NO];
if (_zoneINdex!=-1) {
// [self.pickViewDoc selectRow:_zoneINdex inComponent:2 animated:NO];//gzz0325
}
}
}
_proStrDoc=henam;
_cityStrDoc=city;
_zoneStrDoc=zone;
_ZONEqu=zone;
_isSelectIN=YES;
}
}
else{
[self.view endEditing:YES];
scerocrBol = NO;
}
}
#pragma mark UIPickerView 省市区联动
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 3;
}
//return the # of rows in each component
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
if (component==0) {
return self.dbProvinceMarrayDOc.count;
}else if(component==1){
return self.dbCityMarrayDoc.count;
}else{
return self.dbZoneMarrayDoc.count;
}
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
if (component==0) {
MCLog(@"_isSelectIN_isSelectIN==%d",_isSelectIN);
/**
* 1110
*/
if (row==0) {
_proStrDoc=self.dbProvinceNameDoc[0];
[self selectCityDOC:_proStrDoc];
}
// if (row==1) {
// _proStrDoc=self.dbProvinceNameDoc[1];
// [self selectCityDOC:_proStrDoc];
// }//gzz0324
[pickerView reloadComponent:1];
_zoneStrDoc=@"";
return self.dbProvinceNameDoc[row];
//gzz0324
// MCLog(@"_isSelectIN_isSelectIN==%d",_isSelectIN);
// /**
// * 1110
// */
// if (row==0) {
// _proStrDoc=self.dbProvinceNameDoc[0];
// [self selectCityDOC:_proStrDoc];
// }
// [pickerView reloadComponent:1];
// _zoneStrDoc=@"";
// return self.dbProvinceNameDoc[row];
}else if(component==1){
if (row==0) {
_cityStrDoc=self.dbCityMarrayDoc[0];
}
if (row==1) {
[self selectZoneDOC:_cityStrDoc];
}
[pickerView reloadComponent:2];
if (_isSelectIN) {
[self.pickViewDoc selectRow:_cityINdex inComponent:1 animated:NO];
if ([_ZONEqu isEqualToString:@"1"]) {
_isSelectIN=NO;
}
}
// [self selectZoneDOC:_cityStrDoc];
return self.dbCityMarrayDoc[row];
//
// _cityStrDoc=self.dbCityMarrayDoc[row];//1209
//
//
// if (row==0) {
// _cityStrDoc=self.dbCityMarrayDoc[0];
// [self selectZoneDOC:_cityStrDoc];
// }
// [pickerView reloadComponent:2];
//
// if (_isSelectIN) {
// [self.pickViewDoc selectRow:_cityINdex inComponent:1 animated:NO];
// if ([_ZONEqu isEqualToString:@"1"]) {
// _isSelectIN=NO;
// }
// }
// //
// return self.dbCityMarrayDoc[row];
//
}else{
if (self.dbZoneMarrayDoc==nil||self.dbZoneMarrayDoc.count==0||self.dbZoneMarrayDoc.count==1) {
return @"";
}else{
if (row==0) {
_zoneStrDoc=self.dbZoneMarrayDoc[0];
}
if (row ==_zoneINdex) {
_zoneStrDoc=self.dbZoneMarrayDoc[_zoneINdex];
}
if (_isSelectIN) {
// [self.pickViewDoc selectRow:_zoneINdex inComponent:2 animated:NO];
// _zoneStrDoc=self.dbZoneMarrayDoc[_zoneINdex];
_isSelectIN=NO;
}
return self.dbZoneMarrayDoc[row];
}
// if (self.dbZoneMarrayDoc==nil||self.dbZoneMarrayDoc.count==0) {
// return @"";
// }else{
//
// if (row==0) {
// _zoneStrDoc=self.dbZoneMarrayDoc[0];
// }
//
// if (row ==_zoneINdex) {
// _zoneStrDoc=self.dbZoneMarrayDoc[_zoneINdex];
//
// }
// if (_isSelectIN) {
// [self.pickViewDoc selectRow:_zoneINdex inComponent:2 animated:NO];
// _zoneStrDoc=self.dbZoneMarrayDoc[_zoneINdex];
//
// _isSelectIN=NO;
// }
// return self.dbZoneMarrayDoc[row];
// }
}
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
if (component==0) {
if (row==0) {
}else{
_proStrDoc=self.dbProvinceNameDoc[row];
[self selectCityDOC:_proStrDoc];
[pickerView reloadComponent:1];
[self.dbZoneMarrayDoc removeAllObjects];//
[pickerView reloadComponent:2];
Dlpontlerexple *dlp= [Dlpontlerexple shareIndence];
dlp.cityIdStr=nil;
dlp.countyIdStr=nil;
_cityStrDoc=nil;
_zoneStrDoc=nil;
}
}
else if(component==1){
if (row==0) {
//gzz0325
[self.dbZoneMarrayDoc removeAllObjects];
_zoneStrDoc=nil;
[pickerView reloadComponent:2];
}else{
_cityStrDoc=self.dbCityMarrayDoc[row];
[self selectZoneDOC:_cityStrDoc];
Dlpontlerexple *dlp= [Dlpontlerexple shareIndence];
dlp.countyIdStr=nil;
_zoneStrDoc=nil;
[pickerView reloadComponent:2];
}
}else{
if (row==0) {
}else{
if (self.dbZoneMarrayDoc.count>0) {
_zoneStrDoc=self.dbZoneMarrayDoc[row];
}else{
}
}
}
//gzz0324
// if (component==0) {
//
// _proStrDoc=self.dbProvinceNameDoc[row];
//
// [self selectCityDOC:_proStrDoc];
//
// [pickerView reloadComponent:1];
//
//
// [self.dbZoneMarrayDoc removeAllObjects];//
// [pickerView reloadComponent:2];
//
// Dlpontlerexple *dlp= [Dlpontlerexple shareIndence];
// dlp.cityIdStr=nil;
// dlp.countyIdStr=nil;
// _cityStrDoc=nil;
// _zoneStrDoc=nil;
//
//
//
// }
//
// else if(component==1){
//
//
// _cityStrDoc=self.dbCityMarrayDoc[row];
//
// [self selectZoneDOC:_cityStrDoc];
// Dlpontlerexple *dlp= [Dlpontlerexple shareIndence];
//
// dlp.countyIdStr=nil;
// _zoneStrDoc=nil;
//
// [pickerView reloadComponent:2];
//
// }else{
//
// if (self.dbZoneMarrayDoc.count>0) {
// _zoneStrDoc=self.dbZoneMarrayDoc[row];
//
// }else{
//
//
// }
//
// }
//
}
//GZKeyboary 的 代理
//代理方法
- (void)keyboardDidClickedSure11:(GZKeyboard *)kb{
//2 获取对应的模型
scerocrBol = NO;
MCLog(@"delegate _zoneStr=====%@",_zoneStrDoc);
if(_proStrDoc==nil||_proStrDoc.length==0){
_proStrDoc=@"";
}
if(_cityStrDoc==nil||_cityStrDoc.length==0){
_cityStrDoc=@"";
}
if(_zoneStrDoc==nil||_zoneStrDoc.length==0){
_zoneStrDoc=@"";
}
// NSString *proCity=[NSString stringWithFormat:@"%@%@%@",_proStrDoc,_cityStrDoc,_zoneStrDoc]; gzz0317AAAA
// _addressLLel.text=_cityStrDoc;
if (_zoneStrDoc.length>0) {//gzz0223
_addressLLel.text=_zoneStrDoc;
//gzz0325
if ([_addressLLel.text isEqualToString:@"全部"]) {
_addressLLel.text=_cityStrDoc;
}
}else{
_addressLLel.text=_cityStrDoc;
//gzz0325
if ([_addressLLel.text isEqualToString:@"全部"]) {
_addressLLel.text=_proStrDoc;
}
}
[self.view endEditing:YES];
}
- (void)keyboardDidClickedCancel11:(GZKeyboard *)kb{
//取消键盘
scerocrBol = NO;
[self.view endEditing:YES];
}
/*++++++=======UIPickerView=======datasource=======delegate======*/
//提示信息
-(void)alretview:(NSString *)title{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:@"" preferredStyle:(UIAlertControllerStyleAlert)];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction *action) {
// 点击按钮后的方法直接在这里面写
MCLog(@"取消");
}];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
}
/*=======省市区===开始========*/
//查询语句 省份
-(void)selectProvinceDOC{
if ([_dataBase open]) {
[self.dbProvinceMarrayDOc removeAllObjects];
NSString *strSql = @"SELECT * FROM t_huanzhelast444 ;";
//查询语句 执行的方法
FMResultSet *set = [_dataBase executeQuery:strSql];
while ([set next]) {
NSString *parent = [set stringForColumn:@"parent"];
// [self.dbProvinceMarray addObject:parent];
NSString *str=@"0";
if ([str isEqualToString:parent]) {
[self.dbProvinceMarrayDOc addObject:parent];
NSString *name = [set stringForColumn:@"name"];
[self.dbProvinceNameDoc addObject:name];
// MCLog(@"name==%@",name);
}
}
}
MCLog(@"====省=%zd",self.dbProvinceNameDoc.count);
}
//查询语句 城市
-(void)selectCityDOC:(NSString *)cityName{
if ([_dataBase open]) {
[self.dbCityMarrayDoc removeAllObjects];
NSString *strSql = @"SELECT * FROM t_huanzhelast444 ;";
FMResultSet *set = [_dataBase executeQuery:strSql];
//gzz0324
[self.dbCityMarrayDoc addObject:@"全部"];//gzz0324
while ([set next]) {
NSString *name = [set stringForColumn:@"name"];
if ([cityName isEqualToString:name]) {
NSString *ID= [set stringForColumn:@"_id"];
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM t_huanzhelast444 where treePath=',%@,';",ID];
FMResultSet *set = [_dataBase executeQuery:sql];
while ([set next]) {
NSString *parent = [set stringForColumn:@"parent"];
if ([ID isEqualToString:parent]) {
NSString *name1 = [set stringForColumn:@"name"];
// [self.dbCityMarray removeAllObjects];
// self.dbCityMarray=nil;
[self.dbCityMarrayDoc addObject:name1];
}
}
}
}
}
}
//查询语句 区
-(void)selectZoneDOC:(NSString *)cityName{
if ([_dataBase open]) {
[self.dbZoneMarrayDoc removeAllObjects];
NSString *strSql = @"SELECT * FROM t_huanzhelast444 ;";
FMResultSet *set = [_dataBase executeQuery:strSql];
[self.dbZoneMarrayDoc addObject:@"全部"];//gzz0324
while ([set next]) {
NSString *name = [set stringForColumn:@"name"];
if ([cityName isEqualToString:name]) {
NSString *ID= [set stringForColumn:@"_id"];
NSString *parent = [set stringForColumn:@"parent"];
// MCLog(@"=====parent=%@",parent);
NSString *sql = [NSString stringWithFormat:@"SELECT * FROM t_huanzhelast444 where treePath=',%@,%@,';",parent,ID];
// NSString *sql = @"SELECT name FROM t_huanzhelast444 where treePath=',35,36,';";
FMResultSet *set = [_dataBase executeQuery:sql];
while ([set next]) {
NSString *par = [set stringForColumn:@"parent"];
if ([ID isEqualToString:par]) {
NSString *name2= [set stringForColumn:@"name"];
[self.dbZoneMarrayDoc addObject:name2];
}
}
}
}
// MCLog(@"====zonecount=%zd",self.dbZoneMarray.count);
}
MCLog(@"===区=%zd",self.dbZoneMarrayDoc.count);
}
//将省市区的"省" 转化为 "2" "22"
-(NSString *)convertDOC:(NSString *)procityzoneName {
NSString *strSql =[NSString stringWithFormat:@"SELECT * FROM t_huanzhelast444 where name='%@';",procityzoneName];
FMResultSet *set = [_dataBase executeQuery:strSql];
NSString *IDD=@"";
while ([set next]) {
IDD = [set stringForColumn:@"_id"];
}
_proDOC1=IDD;
return IDD;
}
//将省市区的"市" 转化为 "数字_id"
-(NSString *)convertcityDOC:(NSString *)cityName {
NSString *strSql =[NSString stringWithFormat:@"SELECT * FROM t_huanzhelast444 where treePath=',%@,';",_proDOC1];
FMResultSet *set = [_dataBase executeQuery:strSql];
NSString *cityIDD=@"";
while ([set next]) {
NSString *cityname=[set stringForColumn:@"name"];
if ([cityname isEqualToString:cityName]) {
cityIDD=[set stringForColumn:@"_id"];
_cityDOC1=cityIDD;
return cityIDD;
}
}
// _cityIDD1=cityIDD;
return cityIDD;
}
//将省市区的"区" 转化为 "数字_id"
-(NSString *)convertzoneNameDoc:(NSString *)zoneName {
NSString *strSql1 =[NSString stringWithFormat:@"SELECT * FROM t_huanzhelast444 where treePath=',%@,%@,';",_proDOC1,_cityDOC1];
FMResultSet *set = [_dataBase executeQuery:strSql1];
NSString *zoneIDD=@"";
while ([set next]) {
NSString *zzonename=[set stringForColumn:@"name"];
if ([zzonename isEqualToString:zoneName]) {
zoneIDD=[set stringForColumn:@"_id"];
_zoneDOC1=zoneIDD;
return zoneIDD;
}
}
_zoneDOC1=zoneIDD;
return zoneIDD;
}
/*======省市区 结束===*/
//gzz0407定位
//处理方向变更信息
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
//MCLog(@"heading is %@",userLocation.heading);
}
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
MCLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
// doustrLat=userLocation.location.coordinate.latitude;
// doustrLng = userLocation.location.coordinate.longitude;
// [self locationRequest];
[_locService stopUserLocationService];
CLLocationCoordinate2D pt = (CLLocationCoordinate2D){userLocation.location.coordinate.latitude, userLocation.location.coordinate.longitude};
// CLLocationCoordinate2D pt = (CLLocationCoordinate2D){39.92,116.46};
_geocodesearch = [[BMKGeoCodeSearch alloc]init];
_geocodesearch.delegate = self;
//发起反向地理编码检索
// CLLocationCoordinate2D pt = (CLLocationCoordinate2D){39.915, 116.404};
BMKReverseGeoCodeOption *reverseGeoCodeOption= [[BMKReverseGeoCodeOption alloc] init];
//需要逆地理编码的坐标位置
reverseGeoCodeOption.reverseGeoPoint = pt;
[_geocodesearch reverseGeoCode:reverseGeoCodeOption];
}
- (void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{
MCLog(@"------======解析编码信息....search%@",result);
//BMKReverseGeoCodeResult是编码的结果,包括地理位置,道路名称,uid,城市名等信息
if (error == 0) {
BMKPointAnnotation* item = [[BMKPointAnnotation alloc]init];
item.coordinate = result.location;
item.title = result.address;
//省
NSString *prostr = result.addressDetail.province;
NSString *cityName = result.addressDetail.city;
// result.addressDetail
/** 区,县*/
NSString *district = result.addressDetail.district;
MCLog(@"-login--- %@-城市%@--区-%@",prostr,cityName,district);
Dlpontlerexple *dler = [Dlpontlerexple shareIndence];
dler.logProvIdStr = prostr;
dler.logCityIdStr = cityName;
dler.logCountyIdStr = district;
[_locService stopUserLocationService];
}else{
// MCLog(@"-login--- %@-城市%@--区-%@",prostr,cityName,district);
Dlpontlerexple *dler = [Dlpontlerexple shareIndence];
dler.logProvIdStr = nil;
dler.logCityIdStr = nil;
dler.logCountyIdStr = nil;
[_locService stopUserLocationService];
}
}
//定位
- (void)startLocation11
{
if ([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied){//gzz0708
isLocation=YES;
MBProgressHUD *hub = [[MBProgressHUD alloc] initWithView:self.view];
hub.labelText = @"定位中";
[self.view addSubview:hub];
[hub show:YES];
//设置定位精确度,默认:kCLLocationAccuracyBest
// [BMKLocationService setLocationDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
// //指定最小距离更新(米),默认:kCLDistanceFilterNone gzz0628sdk
// [BMKLocationService setLocationDistanceFilter:100.f];
//初始化BMKLocationService
_locService = [[BMKLocationService alloc]init];
_locService.delegate = self;
//启动LocationService
[_locService startUserLocationService];
//普通态
}//gzz0708一下
else{
isLocation=NO;
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"需要开启定位服务,请到设置->隐私,打开定位服务 肝胆相照->使用应用期间" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
[alertView show];
}
}
#pragma mark collectionview gzz0714
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
if (collectionView == _collectionViewFirst) {
return _dbProvinceNameDoc.count;
}else{
return self.dbCityMarrayDoc.count;
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
if (collectionView == _collectionViewFirst) {
static NSString *identifier = @"cellCollingingSearch";
UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
cell.backgroundColor = [UIColor whiteColor];//gzz0601
// [cell sizeToFit];//gzz0601
cell.layer.borderWidth = 0.5;
cell.layer.borderColor = [[UIColor lightGrayColor] CGColor]; //gzz0530wan
[cell.contentView addSubview:[self cellIndex:indexPath.item collection:collectionView]];
return cell;
}else{
static NSString *identifier = @"cellCollingingSearch22";
UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
cell.backgroundColor = [UIColor whiteColor];//gzz0601
// [cell sizeToFit];//gzz0601
cell.layer.borderWidth = 0.5;
cell.layer.borderColor = [[UIColor lightGrayColor] CGColor]; //gzz0530wan
[cell.contentView addSubview:[self cellIndex:indexPath.item collection:collectionView]];
return cell;
// return nil;
}
}
-(UIView *)cellIndex:(NSInteger)index collection:(UICollectionView *)collectionview{
// CGFloat widthD = (SCREENW-30-20)/3;
CGFloat widthD = (SCREENW-30-10)/3;
UIView *viewdd = [[UIView alloc]initWithFrame:CGRectMake(0, 0, widthD, 30)];
UILabel *labell = [[UILabel alloc]init];
// if (tabMut.count>0) {
viewdd.backgroundColor = [UIColor clearColor];
labell.frame = CGRectMake(0,0 , widthD, 30);
labell.font = [UIFont systemFontOfSize:14];
labell.textAlignment = YES;
if (collectionview == _collectionViewFirst) {
labell.text = [_dbProvinceNameDoc objectAtIndex:index];
}else{
labell.text = [self.dbCityMarrayDoc objectAtIndex:index];
}
[viewdd addSubview:labell];
// labell.text = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:index] objectForKey:@"name"]];
// // labell.text = [NSString stringWithFormat:@"%@",[tabMut objectAtIndex:index] ];
// labell.font = [UIFont systemFontOfSize:13];
// [labell sizeToFit];
// labell.tag = 4022+index;
// labell.textColor = [UIColor grayColor];
// labell.textAlignment = NSTextAlignmentCenter;
// [viewdd addSubview:labell];
// viewdd.frame = CGRectMake(viewdd.x, viewdd.y, labell.width+22, 28);
// labell.centerY = viewdd.centerY;
// labell.centerX = viewdd.centerX;
//
// NSString *names = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:index] objectForKey:@"name"]];
// for (int i=0; i<namesArr.count; i++) {
// if ([namesArr containsObject:names]) {
// labell.textColor = [UIColor colorWithRed:60/255.0 green:199/255.0 blue:192/255.0 alpha:1];
//
// }
// }
//
//
// }
return viewdd;
}
//每个cell的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
// CGFloat widthD = (SCREENW-30-20)/3;
// return CGSizeMake(widthD, 30);
CGFloat widthD = (SCREENW-30-10)/3;
return CGSizeMake(widthD, 30);
}
#pragma mark did
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
if (collectionView == _collectionViewFirst ) {
MCLog(@"选中的是哪个item %zd",indexPath.item);
//通过数组获取到值
NSString *pro = [_dbProvinceNameDoc objectAtIndex:indexPath.item];
[firstBtn setTitle:pro forState:0];
[secondBtn setTitle:@"选择市区" forState:0];
shiquStrr = @"全部";
_addressLLel.text = pro;
[UIView animateWithDuration:0.2 animations:^{
self.showView22.hidden=YES;
self.coverView22.alpha = 0;
} completion:^(BOOL finished) {
[self.coverView22 removeFromSuperview];
self.coverView22=nil;
}];
shengKai = YES;
shengStrr = pro;
[self searchBtnClick:nil];
}else{
MCLog(@"选中的是哪个item %zd",indexPath.item);
//通过数组获取到值
// [firstBtn setTitle:@"省份11" forState:0];
NSString *shiqu = [self.dbCityMarrayDoc objectAtIndex:indexPath.item];
[secondBtn setTitle:shiqu forState:0];
[UIView animateWithDuration:0.2 animations:^{
self.showView22.hidden=YES;
self.coverView22.alpha = 0;
} completion:^(BOOL finished) {
[self.coverView22 removeFromSuperview];
self.coverView22=nil;
}];
MCLog(@"市区的did");
shiquStrr = shiqu;
if ([shiquStrr isEqualToString:@"全部"]) {
_addressLLel.text = shengStrr;
}else{
_addressLLel.text = shiquStrr;
}
[self searchBtnClick:nil];
}
}
距边界缩放大小
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(2, 2, 0, 2);//分别为上、左、下、右
}
@end