YOUPAILCCitySearchView.m 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // YOUPAILCCitySearchView.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/4/15.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCCitySearchView.h"
  9. #import "YOUPAIUCBaseTouchTableView.h"
  10. #import "YOUPAILCCityCell.h"
  11. @interface YOUPAILCCitySearchView()<UITableViewDataSource,UITableViewDelegate,UCBaseTouchTableViewDelegate>
  12. @property(nonatomic,strong)YOUPAIUCBaseTouchTableView* youpaiptableView;
  13. @property(nonatomic,strong)NSMutableArray* youpaipcityArray;
  14. @end
  15. @implementation YOUPAILCCitySearchView
  16. - (YOUPAIUCBaseTouchTableView *)youpaiptableView{
  17. if (!_youpaiptableView) {
  18. _youpaiptableView = [[YOUPAIUCBaseTouchTableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-NavBarHeight) style:UITableViewStylePlain];
  19. _youpaiptableView.touchDelegate = self;
  20. _youpaiptableView.showsVerticalScrollIndicator = NO;
  21. _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  22. _youpaiptableView.backgroundColor = [UIColor whiteColor];
  23. _youpaiptableView.sectionIndexColor = LZA3AABEColor;
  24. _youpaiptableView.sectionIndexBackgroundColor = [UIColor clearColor];
  25. _youpaiptableView.sectionIndexTrackingBackgroundColor = [UIColor clearColor];
  26. _youpaiptableView.delegate = self;
  27. _youpaiptableView.dataSource = self;
  28. if (@available(iOS 15.0, *)) {
  29. _youpaiptableView.sectionHeaderTopPadding = 0;
  30. }
  31. }
  32. return _youpaiptableView;
  33. }
  34. - (instancetype)initWithFrame:(CGRect)frame
  35. {
  36. self = [super initWithFrame:frame];
  37. if (self) {
  38. [self youpaifsetupView];
  39. }
  40. return self;
  41. }
  42. - (void)youpaifsetupView{
  43. self.backgroundColor = [UIColor whiteColor];
  44. self.youpaipcityArray = [NSMutableArray array];
  45. self.youpaiptableView.rowHeight = 48;
  46. [self addSubview:self.youpaiptableView];
  47. }
  48. - (void)youpaifupdateWithString:(NSString*)string{
  49. self.youpaipcityArray = [LCPinYinSortHelper getSearchFullPinyinBY:string];
  50. [self.youpaiptableView reloadData];
  51. }
  52. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  53. return [self.youpaipcityArray count];
  54. }
  55. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  56. YOUPAILCCityCell *cell = [[YOUPAILCCityCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAILCCityCell"];
  57. cell.youpaipcityLabel.text = self.youpaipcityArray[indexPath.row];
  58. [cell bottomLineforViewHeight:48];
  59. return cell;
  60. }
  61. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  62. NSString* city = self.youpaipcityArray[indexPath.row];
  63. if (self.youpaipsearchBlock) {
  64. self.youpaipsearchBlock(city);
  65. }
  66. }
  67. - (void)youpaifdidTouchesBegan:(YOUPAIUCBaseTouchTableView *)tableView{
  68. if (self.youpaipendEditblock) {
  69. self.youpaipendEditblock();
  70. }
  71. }
  72. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  73. if (self.youpaipendEditblock) {
  74. self.youpaipendEditblock();
  75. }
  76. }
  77. @end