// // YOUPAILCCitySearchView.m // LiveChat // // Created by 张灿 on 2018/4/15. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCCitySearchView.h" #import "YOUPAIUCBaseTouchTableView.h" #import "YOUPAILCCityCell.h" @interface YOUPAILCCitySearchView() @property(nonatomic,strong)YOUPAIUCBaseTouchTableView* youpaiptableView; @property(nonatomic,strong)NSMutableArray* youpaipcityArray; @end @implementation YOUPAILCCitySearchView - (YOUPAIUCBaseTouchTableView *)youpaiptableView{ if (!_youpaiptableView) { _youpaiptableView = [[YOUPAIUCBaseTouchTableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-NavBarHeight) style:UITableViewStylePlain]; _youpaiptableView.touchDelegate = self; _youpaiptableView.showsVerticalScrollIndicator = NO; _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone; _youpaiptableView.backgroundColor = [UIColor whiteColor]; _youpaiptableView.sectionIndexColor = LZA3AABEColor; _youpaiptableView.sectionIndexBackgroundColor = [UIColor clearColor]; _youpaiptableView.sectionIndexTrackingBackgroundColor = [UIColor clearColor]; _youpaiptableView.delegate = self; _youpaiptableView.dataSource = self; if (@available(iOS 15.0, *)) { _youpaiptableView.sectionHeaderTopPadding = 0; } } return _youpaiptableView; } - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self youpaifsetupView]; } return self; } - (void)youpaifsetupView{ self.backgroundColor = [UIColor whiteColor]; self.youpaipcityArray = [NSMutableArray array]; self.youpaiptableView.rowHeight = 48; [self addSubview:self.youpaiptableView]; } - (void)youpaifupdateWithString:(NSString*)string{ self.youpaipcityArray = [LCPinYinSortHelper getSearchFullPinyinBY:string]; [self.youpaiptableView reloadData]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [self.youpaipcityArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ YOUPAILCCityCell *cell = [[YOUPAILCCityCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAILCCityCell"]; cell.youpaipcityLabel.text = self.youpaipcityArray[indexPath.row]; [cell bottomLineforViewHeight:48]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ NSString* city = self.youpaipcityArray[indexPath.row]; if (self.youpaipsearchBlock) { self.youpaipsearchBlock(city); } } - (void)youpaifdidTouchesBegan:(YOUPAIUCBaseTouchTableView *)tableView{ if (self.youpaipendEditblock) { self.youpaipendEditblock(); } } - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (self.youpaipendEditblock) { self.youpaipendEditblock(); } } @end