// // MyattentionViewController.m // jitao // // Created by 罗云飞 on 2017/12/8. // Copyright © 2017年 罗云飞. All rights reserved. // #import "MyattentionViewController.h" #import "ZJSliderView.h" #import "WholeViewController.h" #import "AchievementsViewController.h" #import "DemandViewController.h" #import "ExpertViewController.h" #import "PolicyViewController.h" @interface MyattentionViewController (){ WholeViewController *wholevc; AchievementsViewController *achievementsvc; DemandViewController *Demandvc; ExpertViewController *expertvc; PolicyViewController *policyvc; } @end @implementation MyattentionViewController - (void)viewDidLoad { [super viewDidLoad]; [self setNavTitle:@"我的关注"]; // 创建分段控制器 [self createSliderView]; // Do any additional setup after loading the view. } #pragma mark - 创建分段控制器 - (void)createSliderView { self.automaticallyAdjustsScrollViewInsets = NO; UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0.0, NavHeader, SCREEN_WIDTH, 0.8)]; line.backgroundColor = NewLineGrayColor; [self.view addSubview:line]; ZJSliderView *slider = [[ZJSliderView alloc] initWithFrame:CGRectMake(0.0f,NavHeader, SCREEN_WIDTH, SCREEN_HEIGHT-NavHeader)]; __weak typeof(self) weakSelf = self; [slider setNewZJSlider:^(int index) { [weakSelf autoDownRefresh:index]; }]; wholevc = [[WholeViewController alloc] init]; wholevc.title = @"成果"; achievementsvc = [[AchievementsViewController alloc] init]; achievementsvc.title = @"需求"; Demandvc = [[DemandViewController alloc] init]; Demandvc.title = @"专家"; expertvc = [[ExpertViewController alloc] init]; expertvc.title = @"项目"; policyvc = [[PolicyViewController alloc] init]; policyvc.title = @"咨询师"; [slider setViewControllers:@[wholevc,achievementsvc,Demandvc,expertvc,policyvc] owner:self page:_page]; [self.view addSubview:slider]; UIView *controlView = [slider topControlViewWithFrame:CGRectMake(0, ViewStartY, SCREEN_WIDTH, 44) titleLabelWidth:SCREEN_WIDTH/5 page:0]; [self.view addSubview:controlView]; } - (void)autoDownRefresh:(NSInteger)index { if (index == 0) { [wholevc networkRequest:nil]; }else if (index == 1) { [achievementsvc networkRequest:nil]; }else if (index == 2) { [Demandvc networkRequest:nil]; }else if (index == 3) { [expertvc networkRequest:nil]; }else if (index == 4) { [policyvc networkRequest:nil]; } } - (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