ElearningLogVC.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // ElearningLogVC.m
  3. // JSJPCoach
  4. //
  5. // Created by EchoShacolee on 2018/1/30.
  6. // Copyright © 2018年 Danson. All rights reserved.
  7. //
  8. #import "ElearningLogVC.h"
  9. #import "EleOneTableVC.h"
  10. #import "EleTwoTableVC.h"
  11. #import "EleThreeTableVC.h"
  12. #import "EleFourTableVC.h"
  13. @interface ElearningLogVC ()<UIScrollViewDelegate>
  14. @property (strong, nonatomic) UISegmentedControl *seg;
  15. @property (strong, nonatomic) UIScrollView *mainScrView;
  16. @end
  17. @implementation ElearningLogVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.navigationItem.title = [NSString stringWithFormat:@"电子教学日志"];
  21. _seg = [[UISegmentedControl alloc]initWithItems:@[@"科一",@"科二",@"科三",@"科四"]];
  22. _seg.frame = CGRectMake(0, kNavOffSet, kSize.width, 40);
  23. _seg.selectedSegmentIndex = 0;
  24. // _seg.tintColor = COLOR_THEME;
  25. [_seg addTarget:self action:@selector(changeTableview) forControlEvents:UIControlEventValueChanged];
  26. [self.view addSubview:_seg];
  27. NSArray *arr = @[@"EleOneTableVC",@"EleTwoTableVC",@"EleThreeTableVC",@"EleFourTableVC"];
  28. _mainScrView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_seg.frame), kSize.width, kSize.height-CGRectGetMaxY(_seg.frame)-SafeAreaBottomHeight)];
  29. _mainScrView.contentSize = CGSizeMake(kSize.width*arr.count, 0);
  30. _mainScrView.pagingEnabled = YES;
  31. _mainScrView.showsHorizontalScrollIndicator = NO;
  32. _mainScrView.bounces = NO;
  33. _mainScrView.delegate = self;
  34. [self.view addSubview:_mainScrView];
  35. NSInteger i=0;
  36. for (NSString *clsStr in arr) {
  37. Class cls = NSClassFromString(clsStr);
  38. EleBaseTableVC *vc = [[cls alloc]init];
  39. vc.stuDic = self.stuDic;
  40. vc.view.frame = CGRectMake(kSize.width*i++, 0, kSize.width, _mainScrView.height);
  41. [self addChildViewController:vc];
  42. [_mainScrView addSubview:vc.view];
  43. }
  44. }
  45. - (void)didReceiveMemoryWarning {
  46. [super didReceiveMemoryWarning];
  47. // Dispose of any resources that can be recreated.
  48. }
  49. -(void)changeTableview{
  50. [_mainScrView setContentOffset:CGPointMake(kSize.width*_seg.selectedSegmentIndex, 0) animated:NO];
  51. }
  52. -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  53. _seg.selectedSegmentIndex = scrollView.contentOffset.x/kSize.width;
  54. }
  55. /*
  56. #pragma mark - Navigation
  57. // In a storyboard-based application, you will often want to do a little preparation before navigation
  58. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  59. // Get the new view controller using [segue destinationViewController].
  60. // Pass the selected object to the new view controller.
  61. }
  62. */
  63. @end