云豹短视频app源码中,用户定位与位置筛选功能如何实现
在云豹短视频app源码中,用户定位与位置筛选功能部分,使用的是类似通讯录样式的字母排序方式,以及右侧导航直达的跳转模式,这一设置的目的是尽量以最简洁的方式UI、用户最熟悉的排序方式便于用户使用该功能。
接下来我们将从两个步骤分析,该功能如何实现,短视频app源码搭建后的效果图如下:

1.数据处理部分如何实现
NSArray *infoA = [NSArray arrayWithArray:info];
if (_paging == 1) {
[_dataArray removeAllObjects];
[_indexArray removeAllObjects];
_allNums = 0;
}
if (infoA.count <= 0) {
[_tableView.mj_footer endRefreshingWithNoMoreData];
}else {
[_dataArray addObjectsFromArray:infoA];
for (int i = 0; i < infoA.count; i++) {
NSDictionary *subDic = infoA[i];
[_indexArray addObject:minstr([subDic valueForKey:@"title"])];
NSArray *listA = [NSArray arrayWithArray:[subDic valueForKey:@"lists"]];
_allNums += listA.count;
}2. UI显示以及右侧导航直达处理
如何在短视频app源码中实现点击右侧导航,直达目前所在的城市呢?这就需要接入以下代码了:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 30;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *headerVie = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 30)];
NSDictionary *subDic = _dataArray[section];
UILabel *titleL = [[UILabel alloc]init];
titleL.font = SYS_Font(16);
titleL.textColor = RGB_COLOR(@"#323232", 1);
titleL.text = minstr([subDic valueForKey:@"title"]);
[headerVie addSubview:titleL];
[titleL mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(headerVie.mas_left).offset(15);
make.centerY.equalTo(headerVie);
}];
return headerVie;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 50;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return _dataArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSDictionary *subDic = _dataArray[section];
NSArray *listA = @[];
if ([[subDic valueForKey:@"lists"] isKindOfClass:[NSArray class]]) {
listA = [NSArray arrayWithArray:[subDic valueForKey:@"lists"]];
}
return listA.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
YBCitySelCell *cell = [YBCitySelCell cellWithTab:tableView index:indexPath];
NSDictionary *subDic = _dataArray[indexPath.section];
NSArray *listA = @[];
if ([[subDic valueForKey:@"lists"] isKindOfClass:[NSArray class]]) {
listA = [NSArray arrayWithArray:[subDic valueForKey:@"lists"]];
}
cell.cityNameL.text = listA[indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
NSDictionary *subDic = _dataArray[indexPath.section];
NSArray *listA = @[];
if ([[subDic valueForKey:@"lists"] isKindOfClass:[NSArray class]]) {
listA = [NSArray arrayWithArray:[subDic valueForKey:@"lists"]];
}
NSString *cityName = listA[indexPath.row];
if (self.citySelEvent) {
self.citySelEvent(cityName);
}
[self clickNaviLeftBtn];
}
-(NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView{
return _indexArray;
}至此,短视频app源码中类似通讯录格式的位置选择功能就完成了,目前在定位方面,云豹短视频系统大陆地区使用的定位是腾讯地图SDK,它的优势是定位准确,但缺点是大陆外无法使用,大陆外使用的定位系统是谷歌SDK,目前这两家的定位系统是比较准确且好用的。
声明:以上内容为云豹科技原创,未经公司同意,禁止转载,否则将追究相关法律责任www.yunbaokj.com






鲁公网安备 37090202000844号

