STBMKView.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //
  2. // STBMKView.m
  3. // BuguLive
  4. //
  5. // Created by 岳克奎 on 17/4/27.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "STBMKView.h"
  9. @implementation STBMKView
  10. -(instancetype)initWithCoder:(NSCoder *)aDecoder{
  11. if (self = [super initWithCoder:aDecoder]) {
  12. }
  13. return self;
  14. }
  15. -(void)awakeFromNib{
  16. [super awakeFromNib];
  17. [self registerCell];
  18. }
  19. -(void)setDelegate:(id<STBMKViewDelegate>)delegate{
  20. _delegate = delegate;
  21. }
  22. -(void)registerCell{
  23. //文本cell
  24. [self.tableView registerNib:[UINib nibWithNibName:@"STTableDoubleLabCell"
  25. bundle:nil]
  26. forCellReuseIdentifier:@"STTableDoubleLabCell"];
  27. //含有搜索Cell
  28. [self.tableView registerNib:[UINib nibWithNibName:@"STTableSearchCell"
  29. bundle:nil]
  30. forCellReuseIdentifier:@"STTableSearchCell"];
  31. //STTableLeftRightLabCell 只用左侧部分,lab
  32. [self.tableView registerNib:[UINib nibWithNibName:@"STTableLeftRightLabCell"
  33. bundle:nil]
  34. forCellReuseIdentifier:@"STTableLeftRightLabCell"];
  35. }
  36. #pragma mark--- row
  37. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  38. if (section == 0) {
  39. return 1;
  40. }
  41. if (section == 1) {
  42. return 2;
  43. }
  44. if (section == 2) {
  45. return self.dataSoureMArray.count;
  46. }
  47. return 0;
  48. }
  49. #pragma mark -- cell
  50. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  51. //0 区 显示 搜搜
  52. if (indexPath.section == 0) {
  53. STTableSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"STTableSearchCell"
  54. forIndexPath:indexPath];
  55. [cell setDelegate:self];
  56. cell.tableView = self.tableView;
  57. return cell;
  58. }
  59. //1 区
  60. if(indexPath.section == 1){
  61. STTableLeftRightLabCell *cell = [tableView dequeueReusableCellWithIdentifier:@"STTableLeftRightLabCell"
  62. forIndexPath:indexPath];
  63. cell.leftLab.hidden = NO;
  64. cell.rightLab.hidden = YES;
  65. cell.separatorView.hidden = NO;
  66. cell.separatorView.backgroundColor = [UIColor groupTableViewBackgroundColor];
  67. if (indexPath.row == 0) {
  68. cell.leftLab.text = ASLocalizedString(@"不显示");
  69. }else{
  70. cell.leftLab.text = [STBMKCenter shareManager].cityNameStr;
  71. }
  72. [cell.leftLab setFont:[UIFont systemFontOfSize:18]];
  73. [cell.leftLab setTextColor:[UIColor blackColor]];
  74. return cell;
  75. }
  76. if(indexPath.section == 2){
  77. BMKPoiInfo *bmkPoiInfo = self.dataSoureMArray[indexPath.row];
  78. STTableDoubleLabCell *cell = [tableView dequeueReusableCellWithIdentifier:@"STTableDoubleLabCell"
  79. forIndexPath:indexPath];
  80. cell.topLab.text = bmkPoiInfo.name;
  81. cell.topLab.hidden = NO;
  82. cell.bottomLab.text = bmkPoiInfo.address;
  83. cell.bottomLab.hidden = NO;
  84. cell.separatorView.hidden = NO;
  85. cell.separatorView.backgroundColor = [UIColor groupTableViewBackgroundColor];
  86. return cell;
  87. }
  88. return nil;
  89. }
  90. #pragma mark ----- height For Row
  91. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  92. if (indexPath.section == 1) {
  93. return 40;
  94. }
  95. return 50;
  96. }
  97. #pragma mark ----- section Num
  98. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  99. return 3;
  100. }
  101. #pragma ************************** Deleagte协议方法 区域 *********************
  102. #pragma mark ----------------- <STTableSearchCellDeleagte>
  103. #pragma mark ----- 拿到cell
  104. -(void)showSTTableSearchCell:(STTableSearchCell *)stTableSearchCell{
  105. STBMKCenter *stBMKCenter = [STBMKCenter shareManager];
  106. [[BGHUDHelper sharedInstance]syncLoading];
  107. __weak typeof(self)weak_Self = self;
  108. [stBMKCenter showSearchByKeyWords:stTableSearchCell.secrchBar.text
  109. latitude:stBMKCenter.latitudeValue
  110. longitude:stBMKCenter.longitudeValue
  111. andComplete:^(BMKPoiSearch *search,
  112. BMKPoiResult *poiResult,
  113. BMKSearchErrorCode error) {
  114. [[BGHUDHelper sharedInstance]syncStopLoading];
  115. if(poiResult.poiInfoList.count>0){
  116. for (BMKPoiInfo *info in poiResult.poiInfoList) {
  117. NSLog(@"info.name === %@",info.name);
  118. NSLog(@"info.name === %@",info.address);
  119. }
  120. weak_Self.dataSoureMArray = poiResult.poiInfoList.mutableCopy;
  121. stTableSearchCell.secrchBar.text=@"";
  122. [weak_Self.tableView reloadData];
  123. }else{
  124. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"输入恰当的关键字")];
  125. }
  126. }];
  127. }
  128. @end