123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- //
- // Job_Detail_base.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/4/9.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "Job_Detail_base.h"
- @interface Job_Detail_base ()<UIScrollViewDelegate>
- {
- UISegmentedControl * _seg;
- }
- @end
- @implementation Job_Detail_base
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- _tableViews = [[NSMutableArray alloc]init];
-
- _heightsArr = [[NSMutableArray alloc]init];
- _statusArr = [[NSMutableArray alloc]init];
- _keysArr = [[NSMutableArray alloc]init];
- [self setData];
- }
- -(void)setData{
-
- for (int i=0; i<_keysArr.count; i++) {
- [_statusArr addObject:@0];
- [_heightsArr addObject:@normalCellH];
- }
- }
- #pragma mark SegmentControll
- -(void)setSegmentControllWithTitles:(NSArray *)dataArr isBttomBar:(BOOL)isBttombar{
- //
- CGRect frame;
- if (dataArr.count == 1) {
- frame = CGRectMake(0, 0, kSize.width, 0);
- }else{
- frame = CGRectMake(10, 0, kSize.width - 20, JOb_DETAIL_SEGBAR_HEIGHT);
- }
- _seg = [[UISegmentedControl alloc]initWithItems:dataArr];
- _seg.frame = frame;
- _seg.selectedSegmentIndex = 0;
- _seg.tintColor = RQMianColor;
- // _seg.apportionsSegmentWidthsByContent = YES;
- [_seg addTarget:self action:@selector(changeTableview:) forControlEvents:UIControlEventValueChanged];
- [self.view addSubview:_seg];
-
- //1+n
- //
- CGFloat bottomBarH = 0;
-
- //判断是否需要底部处理button
- if (isBttombar) {
- bottomBarH = JOb_DETAIL_BOTTOMBAR_HEIGHT+kSafeAreaBottomHeight;
- }
- _mainScroolView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_seg.frame), kSize.width, kSize.height-kNavOffSet-CGRectGetMaxY(_seg.frame)-bottomBarH)];
- _mainScroolView.pagingEnabled = YES;
- _mainScroolView.bounces = NO;
- _mainScroolView.showsVerticalScrollIndicator = NO;
- _mainScroolView.showsHorizontalScrollIndicator = NO;
- _mainScroolView.delegate = self;
-
- [self.view addSubview:_mainScroolView];
-
- for (int i=0; i<dataArr.count; i++) {
- UITableView * tableview = [[UITableView alloc]initWithFrame:CGRectMake(i*kSize.width, 0, kSize.width, _mainScroolView.frame.size.height) style:UITableViewStylePlain];
- tableview.tableFooterView = [UIView new];
- tableview.delegate = self;
- tableview.dataSource = self;
- [_tableViews addObject:tableview];
- [_mainScroolView addSubview:tableview];
- }
-
- _mainScroolView.contentSize = CGSizeMake(kSize.width*_tableViews.count, 0);
-
- }
- - (void)changeTableview:(UISegmentedControl *)sender{
-
- [_mainScroolView setContentOffset:CGPointMake(kSize.width*sender.selectedSegmentIndex, 0) animated:NO];//yes的话会导致相互影响卡顿
- }
- #pragma mark scroollViewDetagate
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
- {
-
- if ([scrollView isKindOfClass:[UITableView class]]) {
- return;
- }
-
- _seg.selectedSegmentIndex = scrollView.contentOffset.x/kSize.width;
- }
- #pragma mark tableviewDe
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return _keysArr.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
- //缓存高度
- NSNumber *cellHeight = [_heightsArr objectAtIndex:indexPath.row];
-
- if ([cellHeight isEqualToNumber:@normalCellH]) {
-
- CGFloat fontSize = 17;
- NSString *detail = [NSString stringWithFormat:@"%@",self.dataSource[_keysArr[indexPath.row][1]]];
- CGFloat wid = kSize.width - [_keysArr[indexPath.row][0] widthForFont:[UIFont systemFontOfSize:fontSize]] - 46;//46是cell边距20+20+间距6 plus
-
- CGFloat h1 = [self getHeightWithWidth:wid Font:fontSize String:detail]+1+16;//+1 cell与content 16是上下间距
- CGFloat H = h1>normalCellH?h1:normalCellH;
-
- [_heightsArr replaceObjectAtIndex:indexPath.row withObject:[NSNumber numberWithFloat:H]];
- return H;
-
-
- }else{
-
- return [cellHeight floatValue];
- }
- }
- return normalCellH;
-
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- //这里返回的cell是第一个tableview的。下面对于key的判定isequal和contains的区别在于 一个是独有,一个是共有
-
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
-
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
- }
-
-
- NSString * key = _keysArr[indexPath.row][1];
- cell.textLabel.text = _keysArr[indexPath.row][0];
- if ([key containsString:@"_SEX"]) {
- NSString *sex = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- cell.detailTextLabel.text = [sex isEqualToString:@"1"] ? @"男" : @"女" ;
- }else if ([key containsString:@"_EMPLOYSTATUS"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- cell.detailTextLabel.text = [status isEqualToString:@"0"] ? @"在职" : @"离职" ;
- }else if ([key containsString:@"_RECORD_STATUS"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- cell.detailTextLabel.text = [status isEqualToString:@"1"] ? @"已备案" : @"未备案" ;
- }else if ([key containsString:@"_LOCK_STATUS"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- cell.detailTextLabel.text = [status isEqualToString:@"1"] ? @"已锁定" : @"解除锁定" ;
- }else if ([key containsString:@"_OCCUPATIONLEVEL"]){
-
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- switch ([status integerValue]) {
- case 1:
- cell.detailTextLabel.text = @"一级";
- break;
- case 2:
- cell.detailTextLabel.text = @"二级";
- break;
- case 3:
- cell.detailTextLabel.text = @"三级";
- break;
- case 4:
- cell.detailTextLabel.text = @"四级";
- break;
-
- default:
- break;
- }
-
- }else if ([key isEqualToString:@"TCO_PLATECOLOR"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
- //车牌颜色(1:蓝色; 2:黄色; 3:黑色; 4:白色; 5:绿色; 9:其他;)
- switch ([status integerValue]) {
- case 1:
- cell.detailTextLabel.text = @"蓝色";
- break;
- case 2:
- cell.detailTextLabel.text = @"黄色";
- break;
- case 3:
- cell.detailTextLabel.text = @"黑色";
- break;
- case 4:
- cell.detailTextLabel.text = @"白色";
- break;
- case 5:
- cell.detailTextLabel.text = @"绿色";
- break;
- case 9:
- cell.detailTextLabel.text = @"其它";
- break;
- default:
- break;
- }
- }else if ([key isEqualToString:@"AUDITSTUATS"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- cell.detailTextLabel.text = @"审核中";
- switch ([status integerValue]) {
- case 1:
- cell.detailTextLabel.text = @"审核通过";
- break;
- case 2:
- cell.detailTextLabel.text = @"审核拒绝";
- break;
-
- default:
- break;
- }
-
- cell.detailTextLabel.text = [status isEqualToString:@"1"] ? @"审核通过" : @"未备案" ;
- }else{
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[_keysArr[indexPath.row][1]]];
- }
-
- if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
- cell.detailTextLabel.numberOfLines = 0;
- cell.detailTextLabel.textAlignment = NSTextAlignmentLeft;
-
- }else{
- cell.detailTextLabel.numberOfLines = 1;
- cell.detailTextLabel.textAlignment = NSTextAlignmentRight;
- }
-
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if ([_tableViews indexOfObject:tableView] == 0) {
-
- if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
- [_statusArr replaceObjectAtIndex:indexPath.row withObject:@0];
- }else{
- [_statusArr replaceObjectAtIndex:indexPath.row withObject:@1];
- }
-
- [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
-
-
- }
- #pragma mark - 返回合适lable的高度
- -(CGFloat)getHeightWithWidth:(CGFloat)wid Font:(CGFloat)fontSize String:(NSString *)str
- {
- if (str.length == 0) {
- return 0;
- }
-
- UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
- lab.text = str;
- lab.numberOfLines = 0;
- lab.font = [UIFont systemFontOfSize:fontSize];
-
- return [lab sizeThatFits:CGSizeMake(wid, MAXFLOAT)].height;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|