PlaceDetail_VC.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //
  2. // PlaceDetail_VC.m
  3. // Haishenghai-master
  4. //
  5. // Created by GG on 2019/1/10.
  6. // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved.
  7. //
  8. #import "PlaceDetail_VC.h"
  9. #import "Header.h"
  10. @interface PlaceDetail_VC ()<UITableViewDataSource,UITableViewDelegate>
  11. {
  12. UIWebView *callWebview ;
  13. }
  14. @end
  15. @implementation PlaceDetail_VC
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.view.backgroundColor = [UIColor whiteColor];
  19. self.title =@"场所详情";
  20. [self setupUI];
  21. callWebview = [[UIWebView alloc] init];
  22. [self.view addSubview:callWebview];
  23. }
  24. -(void)setupUI{
  25. self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1];
  26. [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
  27. UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  28. [backBtn setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal];
  29. backBtn.frame = CGRectMake(0, 0, 44, 44);
  30. [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  31. backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  32. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
  33. UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
  34. rightButton.frame = CGRectMake(0, 0, 60, 44);
  35. [rightButton setTitle:@"联系人" forState:UIControlStateNormal];
  36. [rightButton addTarget:self action:@selector(confirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
  37. UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
  38. self.navigationItem.rightBarButtonItem = rightItem;
  39. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, HEIGHT) style:UITableViewStylePlain];
  40. // _tableView.backgroundColor = [UIColor grayColor];
  41. _tableView.delegate = self;
  42. _tableView.dataSource = self;
  43. _tableView.userInteractionEnabled = YES;
  44. _tableView.showsHorizontalScrollIndicator=NO;
  45. [self.view addSubview:_tableView];
  46. }
  47. -(void)backClick{
  48. [self.navigationController popViewControllerAnimated:YES];
  49. }
  50. #pragma mark-- tableviewDelegate
  51. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  52. return 1;
  53. }
  54. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  55. return 2;
  56. }
  57. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  58. return 0;
  59. }
  60. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  61. return 5;
  62. }
  63. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  64. UIView *header = [[UIView alloc]init];
  65. // header.frame = CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)
  66. header.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1];
  67. return header;
  68. }
  69. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  70. if (indexPath.section==0) {
  71. return 100;
  72. }else{
  73. return 70;
  74. }
  75. return 0;
  76. }
  77. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  78. static NSString *cellId = @"cell";
  79. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  80. if (!cell) {
  81. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
  82. }
  83. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  84. if (indexPath.section==0) {
  85. for (int i =0; i<3; i++) {
  86. UILabel *titleLab = [[UILabel alloc]init];
  87. titleLab.frame = CGRectMake(10+(WIDTH-20)*(i/3), 5+(25+5)*(i%3), WIDTH-20, 25);
  88. titleLab.tag=i+1;
  89. if (titleLab.tag==1) {
  90. titleLab.text = [NSString stringWithFormat:@"场所名称:%@",_siteName];
  91. }else if (titleLab.tag==2){
  92. titleLab.text = [NSString stringWithFormat:@"区 域:%@",_titleRegionalism];
  93. }else{
  94. titleLab.text = [NSString stringWithFormat:@"详细地址:%@",_titleLocation];
  95. titleLab.numberOfLines =0;
  96. titleLab.lineBreakMode = NSLineBreakByWordWrapping;
  97. }
  98. titleLab.font = [UIFont systemFontOfSize:18];
  99. [cell.contentView addSubview:titleLab];
  100. }
  101. }else{
  102. for (int i =0; i<2; i++) {
  103. UILabel *titleLab = [[UILabel alloc]init];
  104. titleLab.frame = CGRectMake(10+(WIDTH-20)*(i/2), 5+(25+5)*(i%2), WIDTH-20, 25);
  105. titleLab.tag=i+1;
  106. if (titleLab.tag==1) {
  107. NSString *username = [[NSUserDefaults standardUserDefaults]objectForKey:@"username"];
  108. titleLab.text = [NSString stringWithFormat:@"负责人:%@",username];
  109. }else{
  110. NSString *phone =[[NSUserDefaults standardUserDefaults]objectForKey:@"phone"];
  111. titleLab.text = [NSString stringWithFormat:@"手机号:%@",phone];
  112. }
  113. titleLab.font = [UIFont systemFontOfSize:18];
  114. [cell.contentView addSubview:titleLab];
  115. }
  116. UIButton *contectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  117. contectBtn.frame = CGRectMake(WIDTH-54, 13, 44, 44);
  118. [contectBtn setBackgroundImage:[UIImage imageNamed:@"hsh_user_customer"] forState:UIControlStateNormal];
  119. [contectBtn addTarget:self action:@selector(contectBtnCLick) forControlEvents:UIControlEventTouchUpInside];
  120. [cell.contentView addSubview:contectBtn];
  121. }
  122. return cell;
  123. }
  124. - (void)didReceiveMemoryWarning {
  125. [super didReceiveMemoryWarning];
  126. // Dispose of any resources that can be recreated.
  127. }
  128. -(void)confirmBtnClick{
  129. Contacts_VC *cont = [[Contacts_VC alloc]init];
  130. cont.SiteId = _siteID;
  131. [self.navigationController pushViewController:cont animated:YES];
  132. }
  133. -(void)contectBtnCLick{
  134. NSString *phone =[[NSUserDefaults standardUserDefaults]objectForKey:@"phone"];
  135. NSMutableString *str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phone];
  136. [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
  137. }
  138. /*
  139. #pragma mark - Navigation
  140. // In a storyboard-based application, you will often want to do a little preparation before navigation
  141. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  142. // Get the new view controller using [segue destinationViewController].
  143. // Pass the selected object to the new view controller.
  144. }
  145. */
  146. @end