// // SYBase_tbVC.m // LNManager // // Created by EchoShacolee on 2017/4/7. // Copyright © 2017年 lee. All rights reserved. // #import "SYBase_tbVC.h" @interface SYBase_tbVC () @end @implementation SYBase_tbVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = KBackGroundColor; self.navigationController.navigationBar.translucent = NO; [self goBackByNavigation]; _dataSource = [[NSMutableArray alloc]init]; _sectionTitles = [[NSMutableArray alloc]init]; _requsetDic = [[NSMutableDictionary alloc]init]; _tableView = [[UITableView alloc]initWithFrame:kFrame]; _tableView.height = kSize.height - kNavOffSet; _tableView.dataSource = self; _tableView.delegate = self; [self.view addSubview:_tableView]; self.tableView.tableFooterView = [UIView new]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellId"]; self.tableView.sectionIndexColor = RQMianColor; self.tableView.tableFooterView = [UIView new]; self.holderV = [[HolderView alloc] initWithFrame:_tableView.frame]; [self.holderV freshBlock:^{ if (_holdervBlock) { _holdervBlock(); } }]; [self.view addSubview:self.holderV]; } #pragma mark 获取数据 -(void)getDataWithDic:(NSMutableDictionary *)mdic method:(NSString *)method block:(Block)block{ //判断网络是否连接 if (![NetManager connectedToNetWork]) { showMsgUnconnect(); return; } [NetManager requestAnythingWithURL:method dictionary:mdic dataArray:nil completion:^(NSDictionary *root) { [self.holderV setHidden:NO]; if (!root) { ShowMsg(@"数据请求失败,请重试"); return; } if ([root[@"code"] integerValue] == 1) { ShowMsg(root[@"msg"]); return; } if (block) { block(root); } }]; } #pragma mark 弹出框提示 - (void)showMsgByAlertVCWithString:(NSString *)str{ [RQ_SHARE_FUNCTION showAlertWithTitle:nil message:str alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil completion:nil]; } #pragma mark 代理方法 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return _dataSource.count; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [_dataSource[section] count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { return nil; } // 每个分区的页眉 -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [_sectionTitles objectAtIndex:section]; } // 索引目录 -(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { return _sectionTitles; } // 点击目录(响应索引点击) -(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { // 获取所点目录对应的indexPath值 NSIndexPath *selectIndexPath = [NSIndexPath indexPathForRow:0 inSection:index]; // 让table滚动到对应的indexPath位置 [tableView scrollToRowAtIndexPath:selectIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; return index; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end