// // PlaceDetail_VC.m // Haishenghai-master // // Created by GG on 2019/1/10. // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved. // #import "PlaceDetail_VC.h" #import "Header.h" @interface PlaceDetail_VC () { UIWebView *callWebview ; } @end @implementation PlaceDetail_VC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.title =@"场所详情"; [self setupUI]; callWebview = [[UIWebView alloc] init]; [self.view addSubview:callWebview]; } -(void)setupUI{ self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1]; [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}]; UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [backBtn setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal]; backBtn.frame = CGRectMake(0, 0, 44, 44); [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside]; backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn]; UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom]; rightButton.frame = CGRectMake(0, 0, 60, 44); [rightButton setTitle:@"联系人" forState:UIControlStateNormal]; [rightButton addTarget:self action:@selector(confirmBtnClick) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton]; self.navigationItem.rightBarButtonItem = rightItem; _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, HEIGHT) style:UITableViewStylePlain]; // _tableView.backgroundColor = [UIColor grayColor]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.userInteractionEnabled = YES; _tableView.showsHorizontalScrollIndicator=NO; [self.view addSubview:_tableView]; } -(void)backClick{ [self.navigationController popViewControllerAnimated:YES]; } #pragma mark-- tableviewDelegate -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 1; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 0; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 5; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ UIView *header = [[UIView alloc]init]; // header.frame = CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>) header.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1]; return header; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.section==0) { return 100; }else{ return 70; } return 0; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellId = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; if (!cell) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; if (indexPath.section==0) { for (int i =0; i<3; i++) { UILabel *titleLab = [[UILabel alloc]init]; titleLab.frame = CGRectMake(10+(WIDTH-20)*(i/3), 5+(25+5)*(i%3), WIDTH-20, 25); titleLab.tag=i+1; if (titleLab.tag==1) { titleLab.text = [NSString stringWithFormat:@"场所名称:%@",_siteName]; }else if (titleLab.tag==2){ titleLab.text = [NSString stringWithFormat:@"区 域:%@",_titleRegionalism]; }else{ titleLab.text = [NSString stringWithFormat:@"详细地址:%@",_titleLocation]; titleLab.numberOfLines =0; titleLab.lineBreakMode = NSLineBreakByWordWrapping; } titleLab.font = [UIFont systemFontOfSize:18]; [cell.contentView addSubview:titleLab]; } }else{ for (int i =0; i<2; i++) { UILabel *titleLab = [[UILabel alloc]init]; titleLab.frame = CGRectMake(10+(WIDTH-20)*(i/2), 5+(25+5)*(i%2), WIDTH-20, 25); titleLab.tag=i+1; if (titleLab.tag==1) { NSString *username = [[NSUserDefaults standardUserDefaults]objectForKey:@"username"]; titleLab.text = [NSString stringWithFormat:@"负责人:%@",username]; }else{ NSString *phone =[[NSUserDefaults standardUserDefaults]objectForKey:@"phone"]; titleLab.text = [NSString stringWithFormat:@"手机号:%@",phone]; } titleLab.font = [UIFont systemFontOfSize:18]; [cell.contentView addSubview:titleLab]; } UIButton *contectBtn = [UIButton buttonWithType:UIButtonTypeCustom]; contectBtn.frame = CGRectMake(WIDTH-54, 13, 44, 44); [contectBtn setBackgroundImage:[UIImage imageNamed:@"hsh_user_customer"] forState:UIControlStateNormal]; [contectBtn addTarget:self action:@selector(contectBtnCLick) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:contectBtn]; } return cell; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)confirmBtnClick{ Contacts_VC *cont = [[Contacts_VC alloc]init]; cont.SiteId = _siteID; [self.navigationController pushViewController:cont animated:YES]; } -(void)contectBtnCLick{ NSString *phone =[[NSUserDefaults standardUserDefaults]objectForKey:@"phone"]; NSMutableString *str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phone]; [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end