您的位置:首页 > 其它

2016-01-05 y原始数据(-)

2016-01-05 16:43 309 查看
//

// 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"

#define MARGIN 10

@interface SearchDocviewcontroller ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>

{

BOOL isbool;

BOOL isComboBoxHide;

BOOL provinceHide;

BOOL cityHide;

BOOL zoneHide;

// NSMutableArray *searchplaceArray;

NSArray *testData;

NSArray *searchDocArray;

NSArray *disease;

}

@property (nonatomic,strong) NSMutableArray *searchplaceArray;

@property(nonatomic,weak)UITextField *textField;

@property(nonatomic,weak)UITableView *tableview;

@property(nonatomic,strong)UIView *Wholeview;

@property(nonatomic,weak)UILabel *illLabel;

@property(nonatomic,strong)UILabel *zoneLabel;

//view

@property(nonatomic,strong)UIView *comboBox;

@property(nonatomic,strong)UIView *provinceview;

@property(nonatomic,strong)UIView *cityview;

@property(nonatomic,strong)UIView *zoneview;

//病例种类tableview

@property (nonatomic,strong) UITableView *tabComboBox;

//省市区的 tableview

@property (nonatomic,strong) UITableView *tabProvince;

@property (nonatomic,strong) UITableView *tabCity;

@property (nonatomic,strong) UITableView *tabZone;

//病情的种类

@property (nonatomic,strong) UIButton *illcases;

//接受数值的省市区

@property (nonatomic,strong) UIButton *provinceBtn;

@property (nonatomic,strong) UIButton *cityBtn;

@property (nonatomic,strong) UIButton *zoneBtn;

@property (nonatomic,assign)NSInteger currentIndex;

//王建自定义的 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;

//数据库

@property (nonatomic,strong) NSMutableArray *dbProvinceMarray;

@property (nonatomic,strong) NSMutableArray *dbProvinceName;

@property (nonatomic,strong) NSMutableArray *dbCityMarray;

@property (nonatomic,strong) NSMutableArray *dbZoneMarray;

@end

static FMDatabase *_dataBase;

@implementation SearchDocviewcontroller

//-(NSMutableArray *)dbProvinceMarray{

// if (_dbProvinceMarray) {

// _dbProvinceMarray=[NSMutableArray array];

// }

// return _dbProvinceMarray;

//}

-(NSMutableArray *)searchplaceArra{

if (_searchplaceArray==nil) {

_searchplaceArray=[[NSMutableArray alloc]init];

}

return _searchplaceArray;

}

- (void)viewDidLoad {

[super viewDidLoad];

//1.创建数据库 指定数据库的路径 一次

NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingPathComponent:@"huanzhelast.sqlite"];

_dataBase = [FMDatabase databaseWithPath:path];

// NSLog(@"%@",path);

self.dbProvinceMarray = [NSMutableArray array];

self.dbProvinceName = [NSMutableArray array];

BOOL success = [_dataBase open];

if (success) {

NSLog(@"创建数据库成功!");

//2.创建表 字段 ()

// id 主键 fullname 全称 name 名字 treePath 树路径 parent 父类

//2.创建表

NSString *str = @"CREATE TABLE IF NOT EXISTS t_huanzhelast(id integer PRIMARY KEY AUTOINCREMENT , fullname text NOT NULL,name text NOT NULL, parent text NOT NULL,treePath text NOT NULL);";

if ([_dataBase executeUpdate:str]) {

NSLog(@"表创建成功!");

}else{

NSLog(@"创建表失败!");

}

}else{

NSLog(@"创建数据库失败!");

}

self.title=@"找医生";

//字体大小

[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor blueColor]}];//蓝色 找专家

// 自定义后退按钮

UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"NavBack"] originalImage]

style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];

self.navigationItem.leftBarButtonItem=backItem;

//自定义后退按钮后,手势返回上一级控制器的功能恢复

self.navigationController.interactivePopGestureRecognizer.delegate = nil;

self.view.backgroundColor=[UIColor clearColor];//不写这的话 出不来

[self contents];//主题布局

[self illcaseView];//病例种类view

[self provinceView];//省份 view

[self cityView]; // 城市 view

[self zoneView]; //区 view

[self zoneview];

testData=[[NSArray alloc]initWithObjects:@"北京市",@"天津市",@"上海市",@"4",@"5",@"6",@"7",@"8",@"9",@"0",nil];

// if (数据库中的表存在) {

// [self areaRequest];

// }

[self diseaseRequest];

// [self saveData];

[self saveData];

}

-(void)areaRequest

{

AFHTTPRequestOperationManager *manger = [[AFHTTPRequestOperationManager alloc]init];

manger.responseSerializer = [AFHTTPResponseSerializer serializer];

NSString *str = [NSString stringWithFormat:@"%@/areaList",Public_URL];

[manger POST:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:operation.responseData options:NSJSONReadingAllowFragments error:nil];

_searchplaceArray = dic[@"data"];

[self saveData];

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"省市区__请求失败!111");

}];

}

//保存到数据库的省市区 数据

-(void)saveData{

for (int i=0; i<_searchplaceArray.count; i++) {

NSString *fullname=[[_searchplaceArray objectAtIndex:i] objectForKey:@"fullName"];

NSString *treePath=[[_searchplaceArray objectAtIndex:i] objectForKey:@"treePath"];

NSString *name=[[_searchplaceArray objectAtIndex:i] objectForKey:@"name"];

// NSNumber *parent1=[[_searchplaceArray objectAtIndex:i] objectForKey:@"parent"];

// NSInteger parent=[parent1 integerValue];

NSString *parent=[[_searchplaceArray objectAtIndex:i] objectForKey:@"parent"];

BOOL success = [_dataBase executeUpdate:@"INSERT INTO t_huanzhelast(fullname, name, parent,treePath) VALUES(?,?,?,?);",fullname,name,parent,treePath];

if (success) {

// NSLog(@"添加成功!");

}else{

NSLog(@"添加失败!");

}

}

[self selectProvince];

}

//查询语句 省份

-(void)selectProvince{

NSString *strSql = @"SELECT * FROM t_huanzhelast where parent = 0;";

//查询语句 执行的方法

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.dbProvinceMarray addObject:parent];

//

// NSString *name = [set stringForColumn:@"name"];

// [self.dbProvinceName addObject:name];

// NSLog(@"name==%@",name);

// }

}

NSLog(@"==sp%zd",self.dbProvinceMarray.count);

}

-(void)docListRequest{

AFHTTPRequestOperationManager *manger = [[AFHTTPRequestOperationManager alloc]init];

manger.responseSerializer = [AFHTTPResponseSerializer serializer];

NSString *str = [NSString stringWithFormat:@"%@/expertList",Public_URL];

NSMutableDictionary *mdict=[[NSMutableDictionary alloc]init];

mdict[@"realName"]=@"张***";

mdict[@"hospitalName"]=@"郑大一附院";

mdict[@"diseaseUuid"]=@"丙肝";

mdict[@"provId"]=@"河南省";

mdict[@"cityId"]=@"郑州市";

mdict[@"countyId"]=@"金水区";

mdict[@"page"]=@"3";

[manger POST:str parameters:mdict success:^(AFHTTPRequestOperation *operation, id responseObject) {

NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:operation.responseData options:NSJSONReadingAllowFragments error:nil];

searchDocArray = dic[@"date"];

[self.tableview reloadData];

NSLog(@"--附近的医生--%@----",dic);

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"附近的医生___请求失败!111");

}];

}

-(void)diseaseRequest{

// "uuid": "123",//唯一标识

// "name": "肝硬化",//标签名称

// "des": "肝硬化" //标签描述

AFHTTPRequestOperationManager *manger = [[AFHTTPRequestOperationManager alloc]init];

manger.responseSerializer = [AFHTTPResponseSerializer serializer];

NSString *str = [NSString stringWithFormat:@"%@/disease",Public_URL];

// NSMutableDictionary *mdict=[[NSMutableDictionary alloc]init];

[manger POST:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

NSDictionary *diseaseDic = [NSJSONSerialization JSONObjectWithData:operation.responseData options:NSJSONReadingAllowFragments error:nil];

disease = diseaseDic[@"date"];

// NSLog(@"-疾病--%@--",diseaseDic);

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"获取肝胆病标签_失败!111");

}];

}

-(void)contents{

//手写自动布局

UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20,84,SCREENW*0.68, 40)];//x y 宽 高

self.textField=text;

text.borderStyle = UITextBorderStyleRoundedRect;

// text.backgroundColor = [UIColor blackColor];

text.placeholder = @"搜索专家医生";

// text.font = [UIFont fontWithName:@"Arial" size:20.0f];

text.font=[UIFont systemFontOfSize:15];

text.textColor = [UIColor blackColor];

//输入框中是否有个叉号,在什么时候显示,用于一次性删除输入框中的内容

text.clearButtonMode = UITextFieldViewModeAlways;

//再次编辑就清空

text.clearsOnBeginEditing = YES;

//内容对齐方式

text.textAlignment = NSTextAlignmentLeft;

text.delegate=self;

[self.view addSubview:text];

//textfield 右侧的button

UIButton *searchBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];

// UIButton *searchBtn=[UIButton buttonWithType:UIButtonTypeSystem];

//加上边框

[searchBtn.layer setBorderColor:[UIColor grayColor].CGColor];

[searchBtn.layer setBorderWidth:1];

searchBtn.layer.cornerRadius=YES;

[searchBtn.layer setMasksToBounds:YES];

CGFloat btnX=CGRectGetMaxX(text.frame)+MARGIN*0.5;

CGFloat btnY=text.y;

CGFloat btnW=80;//要改

CGFloat btnH=text.height;

searchBtn.frame=CGRectMake(btnX, btnY, btnW, btnH);

[searchBtn setTitle:@"搜索" forState:UIControlStateNormal];

searchBtn.backgroundColor=[UIColor clearColor];

searchBtn.titleLabel.font=[UIFont systemFontOfSize:18];

[searchBtn addTarget:self action:@selector(searchBtnClick:)

forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:searchBtn];

//

//UILabel 按疾病

CGFloat LabelX=20;

CGFloat LabelY=CGRectGetMaxY(text.frame)+MARGIN*0.75;

CGFloat LabelW=text.frame.size.width*0.25;

CGFloat LabelH=text.height;

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(LabelX, LabelY, LabelW, LabelH)];

self.illLabel=label;

[self.view addSubview:label];

label.backgroundColor = [UIColor clearColor];

label.text = @"按疾病";

label.font=[UIFont systemFontOfSize:18];

//

//textfield 右侧的button

UIButton *illcaseBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];

//加上边框

[illcaseBtn.layer setBorderColor:[UIColor grayColor].CGColor];

[illcaseBtn.layer setBorderWidth:1];

illcaseBtn.layer.cornerRadius=YES;

[illcaseBtn.layer setMasksToBounds:YES];

CGFloat illcaseX=CGRectGetMaxX(label.frame);

CGFloat illcaseY=label.y*1.07;

CGFloat illcaseW=text.frame.size.width*0.35;

CGFloat illcaseH=text.height*0.6;

illcaseBtn.frame=CGRectMake(illcaseX, illcaseY, illcaseW, illcaseH);

[illcaseBtn setTitle:@"选择种类" forState:UIControlStateNormal];

illcaseBtn.backgroundColor=[UIColor clearColor];

illcaseBtn.titleLabel.font=[UIFont systemFontOfSize:18];

[illcaseBtn addTarget:self action:@selector(illcaseBtnClick)

forControlEvents:UIControlEventTouchUpInside];

self.illcases=illcaseBtn;

[self.view addSubview:illcaseBtn];

//UIlabel 按地区 // 省 市 区

CGFloat zonelabelX=20;

CGFloat zonelabelY=CGRectGetMaxY(label.frame)+MARGIN;

CGFloat zonelabelW=text.frame.size.width*0.25;

CGFloat zonelabelH=text.height;

UILabel *zoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(zonelabelX, zonelabelY, zonelabelW, zonelabelH)];

self.zoneLabel=zoneLabel;

[self.view addSubview:zoneLabel];

zoneLabel.backgroundColor = [UIColor clearColor];

zoneLabel.text = @"按地区";

zoneLabel.font=[UIFont systemFontOfSize:18];

NSArray *namearr = [NSArray arrayWithObjects:@"省份",@"城市",@" 区", nil];

for (int i=0; i<3; i++) {

UIButton *select=[UIButton buttonWithType:UIButtonTypeRoundedRect];

if (i==0) {

self.provinceBtn=select;

}else if(i==1){

self.cityBtn=select;

}else{

self.zoneBtn=select;

}

//加上边框

[select.layer setBorderColor:[UIColor grayColor].CGColor];

[select.layer setBorderWidth:1];

select.layer.cornerRadius=YES;

[select.layer setMasksToBounds:YES];

CGFloat selectX=CGRectGetMaxX(zoneLabel.frame)+text.frame.size.width*0.3*i+MARGIN;

CGFloat selectY=CGRectGetMaxY(label.frame)+MARGIN;

CGFloat selectW=text.frame.size.width*0.25;

CGFloat selectH=text.height*0.8;

select.frame = CGRectMake(selectX, selectY, selectW,selectH);

[select setTitle:[namearr objectAtIndex:i] forState:0];

select.tag = i;

[select addTarget:self action:@selector(btnselect:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:select];

}

//tableview 医生简介

CGFloat tableviewX=0;

CGFloat tableviewY=CGRectGetMaxY(zoneLabel.frame)+MARGIN;;

CGFloat tableviewW=SCREENW;

CGFloat tableviewH=SCREENH-tableviewY;

UITableView *tableView=[[UITableView alloc] initWithFrame:CGRectMake(tableviewX, tableviewY, tableviewW, tableviewH)];

self.tableview=tableView;

self.tableview.dataSource=self;

self.tableview.delegate=self;

[self.view addSubview:self.tableview];

}

//搜索的点击

-(void)searchBtnClick:(NSString *)str{

self.comboBox.hidden=YES;

self.provinceview.hidden=YES;

self.cityview.hidden=YES;

self.zoneview.hidden=YES;

[self docListRequest];//专家列表信息

// 需要返回的值

// “data”:[{

// “realName”:””,//真实姓名

// “positionName”:””,//职称

// “hospitalName”:””,//医院名称

// “photo”:””,//头像

// “specialities”:””//专长

// }]

////

// UIImageView *headImage = (UIImageView *)[self.headImage viewWithTag:1001];

// headImage.image =[[searchDocArray objectAtIndex:indexPath.row] objectForKey:@"photo"];

[self.view endEditing:YES];

}

//病例种类 button

-(void)illcaseBtnClick{

// NSLog(@"病例种类");

if (isComboBoxHide==NO) {

_comboBox.hidden = NO;

isComboBoxHide=YES;

}

else{

_comboBox.hidden = YES;

isComboBoxHide = NO;

}

self.provinceview.hidden=YES;

self.cityview.hidden=YES;

self.zoneview.hidden=YES;

[self.view endEditing:YES];

}

//省市区 选择

- (void)btnselect:(UIButton *)sender

{

// NSLog(@"===========%zd",sender.tag);

switch (sender.tag) {

case 0:

{

if (provinceHide==NO) {

_provinceview.hidden = NO;

provinceHide=YES;

}

else{

_provinceview.hidden = YES;

provinceHide = NO;

}

self.comboBox.hidden=YES;

self.cityview.hidden=YES;

self.zoneview.hidden=YES;

[self.view endEditing:YES];

}

break;

case 1:

{

if (cityHide==NO) {

_cityview.hidden = NO;

cityHide=YES;

}

else{

_cityview.hidden = YES;

cityHide = NO;

}

self.comboBox.hidden=YES;

self.provinceview.hidden=YES;

self.zoneview.hidden=YES;

[self.view endEditing:YES];

}

break;

case 2:

{

if (zoneHide==NO) {

_zoneview.hidden = NO;

zoneHide=YES;

}

else{

_zoneview.hidden = YES;

zoneHide = NO;

}

self.comboBox.hidden=YES;

self.provinceview.hidden=YES;

self.cityview.hidden=YES;

[self.view endEditing:YES];

}

default:

break;

}

[self.view endEditing:YES];

}

//点击任何一个按钮,其他的消失 没有用到

-(void)touchLost{

self.comboBox.hidden=YES;

self.provinceview.hidden=YES;

self.cityview.hidden=YES;

self.zoneview.hidden=YES;

[self.view endEditing:YES];

}

//病例种类 view

-(void)illcaseView{

// UIview 点击时里面加载的时tableview

UIView *ComboBox=[[UIView alloc]init];

self.comboBox=ComboBox;

CGFloat ComboBoxX=20;

CGFloat ComboBoxY=CGRectGetMaxY(self.illLabel.frame)+MARGIN*0.5;

CGFloat ComboBoxW=SCREENW*0.7;

CGFloat ComboBoxH=SCREENH*0.7;

ComboBox.frame=CGRectMake(ComboBoxX, ComboBoxY, ComboBoxW, ComboBoxH);

ComboBox.backgroundColor=[UIColor yellowColor];

ComboBox.hidden=YES;

[self.view addSubview:ComboBox];

//向combobox中添加tableview

_tabComboBox=[[UITableView alloc]init];

_tabComboBox.delegate=self;

_tabComboBox.dataSource=self;

_tabComboBox.frame=CGRectMake(0, 0,ComboBoxW, 900);

[self.comboBox addSubview:_tabComboBox];

}

//省份 view

-(void)provinceView{

// UIview 点击时里面加载的时tableview

UIView *province=[[UIView alloc]init];

self.provinceview=province;

CGFloat provinceX=20;

CGFloat provinceY=CGRectGetMaxY(self.zoneLabel.frame)+MARGIN*0.5;

CGFloat provinceW=SCREENW*0.7;

CGFloat provinceH=SCREENH*0.7;

province.frame=CGRectMake(provinceX, provinceY, provinceW, provinceH);

province.backgroundColor=[UIColor clearColor];

province.hidden=YES;

[self.view addSubview:province];

// NSLog(@"省份");

//向combobox中添加tableview

_tabProvince=[[UITableView alloc]init];

_tabProvince.delegate=self;

_tabProvince.dataSource=self;

_tabProvince.frame=CGRectMake(0, 0,provinceW, 900);

[self.provinceview addSubview:_tabProvince];

}

//市 view

-(void)cityView{

// UIview 点击时里面加载的时tableview

UIView *cityView=[[UIView alloc]init];

self.cityview=cityView;

CGFloat provinceX=80;

CGFloat provinceY=CGRectGetMaxY(self.zoneLabel.frame)+MARGIN*0.5;

CGFloat provinceW=SCREENW*0.7;

CGFloat provinceH=SCREENH*0.7;

cityView.frame=CGRectMake(provinceX, provinceY, provinceW, provinceH);

cityView.backgroundColor=[UIColor orangeColor];

cityView.hidden=YES;

[self.view addSubview:cityView];

//向combobox中添加tableview

_tabCity=[[UITableView alloc]init];

_tabCity.delegate=self;

_tabCity.dataSource=self;

_tabCity.frame=CGRectMake(0, 0,provinceW, 900);

[self.cityview addSubview:_tabCity];

}

//区 view

-(void)zoneView{

// UIview 点击时里面加载的时tableview

UIView *zoneView=[[UIView alloc]init];

self.zoneview=zoneView;

CGFloat provinceW=SCREENW*0.7;

CGFloat provinceX=100;

CGFloat provinceY=CGRectGetMaxY(self.zoneLabel.frame)+MARGIN*0.5;

CGFloat provinceH=SCREENH*0.7;

zoneView.frame=CGRectMake(provinceX, provinceY, provinceW, provinceH);

zoneView.backgroundColor=[UIColor orangeColor];

zoneView.hidden=YES;

[self.view addSubview:zoneView];

//向combobox中添加tableview

_tabZone=[[UITableView alloc]init];

_tabZone.delegate=self;

_tabZone.dataSource=self;

_tabZone.frame=CGRectMake(0, 0,provinceW, 900);

[self.zoneview addSubview:_tabZone];

}

//返回上一级 pop

-(void)backClick{

[self.navigationController popViewControllerAnimated:YES];

}

#pragma UITextfield delegate

- (void)textFieldDidBeginEditing:(UITextField *)textField{

[self.textField becomeFirstResponder];

}

- (BOOL)textFieldShouldReturn:(UITextField *)textField

{

[self.textField resignFirstResponder];

return YES;

}

#pragma datasource delegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{ if(tableView==_tabComboBox){

return 40;

} else if(tableView==_tabProvince){

return 40;

}else if(tableView==_tabCity){

return 40;

}else if(tableView==_tabZone){

return 40;

}

else{

return 120;//专家简介长度

}

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

if (tableView==_tabComboBox) {

return 10;//病情种类下拉列表

}else if (tableView==_tabProvince) {

return self.dbProvinceName.count ;//省份

// NSLog(@"=====%zd",searchplaceArray.count);

}else if (tableView==_tabCity) {

return 10;;//城市

}else if (tableView==_tabZone) {

return 10;//qu

}

else

{

return 3;//专家简介长度

}

}

- (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];

}

// //数据请求 接口

// [self diseaseRequest]; 这是错误的

cell.textLabel.text=[[disease objectAtIndex:indexPath.row] objectForKey:@"name"];

return cell;

} else if (tableView==_tabProvince) {

//省份

static NSString *procell=@"procell";

UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:procell];

if (!cell) {

cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:procell];

}

cell.textLabel.text=[self.dbProvinceName objectAtIndex:indexPath.row];

return cell;

} else if (tableView==_tabCity) {

//chengshi

static NSString *cityCell=@"citycell";

UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cityCell];

if (!cell) {

cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cityCell];

}

cell.textLabel.text=[testData objectAtIndex:indexPath.row];

return cell;

}else if (tableView==_tabZone) {

//区

static NSString *zoneCell=@"zonecell";

UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:zoneCell];

if (!cell) {

cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:zoneCell];

}

cell.textLabel.text=[testData objectAtIndex:indexPath.row];

return cell;

}

else {

//专家简介长度

static NSString *cellIn=@"cellIN";

UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIn ];

if (!cell) {

cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIn];

}

// self.currentIndex=(int)indexPath.row;

cell.selectionStyle = UITableViewCellSelectionStyleNone;

[cell.contentView addSubview:[self CellFview:(int)indexPath.row]]; //在 cell的contentView 中添加了一个自定义的view 就相当于给cell自定义了

UIImageView *headImage = (UIImageView *)[self.headImage viewWithTag:1001];

headImage.image =[[searchDocArray objectAtIndex:indexPath.row] objectForKey:@"photo"];

return cell;

}

}

//自定义的 cell

- (UIView *)CellFview:(int)cellsend

{

UIView *packagingView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 120)];

UIImageView *headimage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"hearn"]];

headimage.tag=1001;

headimage.frame = CGRectMake(0, 20, 100, 100);

[packagingView addSubview:headimage];

UIButton *buttonimage = [UIButton buttonWithType:UIButtonTypeCustom];

buttonimage.frame = CGRectMake(0, 20, 100, 100);

[buttonimage addTarget:self action:@selector(imageBtn:) forControlEvents:UIControlEventTouchUpInside];

buttonimage.tag = cellsend;

[packagingView addSubview:buttonimage];

UILabel *labname = [[UILabel alloc]initWithFrame:CGRectMake(120, 20, 150, 20)];

self.labname=labname;

[packagingView addSubview:labname];

UILabel *labpost = [[UILabel alloc]initWithFrame:CGRectMake(120, 40, 150, 20)];

labpost.text = @"职 称:";

[packagingView addSubview:labpost];

UILabel *labyiy = [[UILabel alloc]initWithFrame:CGRectMake(120, 60, 150, 20)];

labyiy.text = @"坐诊医院:";

[packagingView addSubview:labyiy];

UILabel *labzhuanchang = [[UILabel alloc]initWithFrame:CGRectMake(120, 80, 150, 20)];

labzhuanchang.text = @"专 长:";

[packagingView addSubview:labzhuanchang];

UILabel *labSelvie = [[UILabel alloc]initWithFrame:CGRectMake(120, 100, 70, 20)];

labSelvie.text = @"服 务:";

[packagingView addSubview:labSelvie];

UIButton *Selverbtn = [UIButton buttonWithType:UIButtonTypeCustom];

Selverbtn.frame = CGRectMake(190, 100, 30, 20);

Selverbtn.backgroundColor = [UIColor purpleColor];

[packagingView addSubview:Selverbtn];

UIButton *Selverbtnb = [UIButton buttonWithType:UIButtonTypeCustom];

Selverbtnb.frame = CGRectMake(230, 100, 30, 20);

Selverbtnb.backgroundColor = [UIColor purpleColor];

[packagingView addSubview:Selverbtnb];

UIButton *Selverbtnd = [UIButton buttonWithType:UIButtonTypeCustom];

Selverbtnd.frame = CGRectMake(270, 100, 30, 20);

Selverbtnd.backgroundColor = [UIColor purpleColor];

[packagingView addSubview:Selverbtnd];

return packagingView;

}

//tabelview的代理 可以获得选中view的值

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

if(tableView==_tabComboBox){

UITableViewCell *comboxcell = [tableView cellForRowAtIndexPath:indexPath];

[self.illcases setTitle:comboxcell.textLabel.text forState:0];

} else if(tableView==_tabProvince){

UITableViewCell *provincecell= [tableView cellForRowAtIndexPath:indexPath];

[self.provinceBtn setTitle:provincecell.textLabel.text forState:0];

}else if(tableView==_tabCity){

UITableViewCell *citycell= [tableView cellForRowAtIndexPath:indexPath];

[self.cityBtn setTitle:citycell.textLabel.text forState:0];

}else if(tableView==_tabZone){

UITableViewCell *zonecell = [tableView cellForRowAtIndexPath:indexPath];

[self.zoneBtn setTitle:zonecell.textLabel.text forState:0];

}

else{

UITableViewCell *headcell = [tableView cellForRowAtIndexPath:indexPath];

}

self.comboBox.hidden=YES;

self.provinceview.hidden=YES;

self.cityview.hidden=YES;

self.zoneview.hidden=YES;

[self.view endEditing:YES];

}

- (void)imageBtn:(UIButton *)buttnDer

{

// NSLog(@"z专家头像点击 =----searchDoc 中");

DocDetailViewController *docDetail=[[DocDetailViewController alloc]init];

[self.navigationController pushViewController:docDetail animated:YES];

}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: