NotifySelectObjVC.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. //
  2. // NotifySelectObjVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/6/21.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "NotifySelectObjVC.h"
  9. #import "Notify_SelectSchVC.h"//选择驾校
  10. #import "Notify_SelectCityVC.h"//选择地市
  11. #import "SendNotifyVC.h"//编写通知
  12. @interface NotifySelectObjVC ()<UIScrollViewDelegate>
  13. {
  14. UITableView *_schTableView;
  15. UITableView *_cityTableView;
  16. UIScrollView *_mainScroolView;
  17. UISegmentedControl *_seg;
  18. NSString *_type;//类型 1 给管理部门 2 给驾校
  19. }
  20. @end
  21. @implementation NotifySelectObjVC
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. [self myInit];
  25. }
  26. -(void)myInit{
  27. NSArray *titles = @[@"通知驾校",@"通知地市管理员"];
  28. _seg = [[UISegmentedControl alloc]initWithItems:titles];
  29. _seg.frame = CGRectMake(10, kNavOffSet, kSize.width-20, 40);
  30. _seg.tintColor = COLOR_THEME;
  31. _seg.backgroundColor = [UIColor whiteColor];
  32. _seg.selectedSegmentIndex = 0;
  33. [_seg addTarget:self action:@selector(changeTableview:) forControlEvents:UIControlEventValueChanged];
  34. [self.view addSubview:_seg];
  35. _mainScroolView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 40+kNavOffSet, kSize.width, kSize.height-CGRectGetMaxY(_seg.frame))];
  36. _mainScroolView.pagingEnabled = YES;
  37. _mainScroolView.bounces = NO;
  38. _mainScroolView.showsVerticalScrollIndicator = NO;
  39. _mainScroolView.showsHorizontalScrollIndicator = NO;
  40. _mainScroolView.delegate = self;
  41. _mainScroolView.contentSize = CGSizeMake(kSize.width*titles.count, 0);
  42. [self.view addSubview:_mainScroolView];
  43. //驾校
  44. Notify_SelectSchVC * vc = [[Notify_SelectSchVC alloc]init];
  45. vc.type = 8;
  46. __weak typeof(self) weakSelf = self;
  47. vc.blcok = ^(NSArray *ids) {
  48. _type = @"2";
  49. [weakSelf sendNotifyWithIDs:ids];
  50. };
  51. vc.view.frame = CGRectMake(0, 0, kSize.width, _mainScroolView.frame.size.height);
  52. [self addChildViewController:vc];
  53. _schTableView = vc.tableView;
  54. _schTableView.frame = vc.view.frame;
  55. [_mainScroolView addSubview:vc.view];
  56. //地市
  57. Notify_SelectCityVC * city = [[Notify_SelectCityVC alloc]init];
  58. city.blcok = ^(NSArray *ids) {
  59. _type = @"1";
  60. [weakSelf sendNotifyWithIDs:ids];
  61. };
  62. city.goSchBlock = ^{
  63. _seg.selectedSegmentIndex = 0;
  64. [_mainScroolView setContentOffset:CGPointMake(0, 0) animated:NO];
  65. };
  66. city.view.frame = CGRectMake(kSize.width, 0, kSize.width, _mainScroolView.frame.size.height);
  67. [self addChildViewController:city];
  68. _cityTableView = city.tableView;
  69. _cityTableView.frame = CGRectMake(0, 0, city.view.frame.size.width, city.view.frame.size.height);
  70. [_mainScroolView addSubview:city.view];
  71. }
  72. - (void)changeTableview:(UISegmentedControl *)sender{
  73. // if (_schTableView.editing || _cityTableView.editing) {
  74. // return;
  75. // }
  76. [_mainScroolView setContentOffset:CGPointMake(kSize.width*sender.selectedSegmentIndex, 0) animated:NO];//yes的话会导致相互影响卡顿
  77. }
  78. #pragma mark scroollViewDetagate
  79. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  80. {
  81. if ([scrollView isKindOfClass:[UITableView class]]) {
  82. return;
  83. }
  84. _seg.selectedSegmentIndex = scrollView.contentOffset.x/kSize.width;
  85. }
  86. //-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
  87. //
  88. // if (_schTableView.editing || _cityTableView.editing) {
  89. // return;
  90. // }
  91. //}
  92. -(void)sendNotifyWithIDs:(NSArray *)ids{
  93. SendNotifyVC * vc = [[SendNotifyVC alloc]init];
  94. vc.ids = ids;
  95. vc.type = _type;
  96. [self.navigationController pushViewController:vc animated:YES];
  97. }
  98. - (void)didReceiveMemoryWarning {
  99. [super didReceiveMemoryWarning];
  100. // Dispose of any resources that can be recreated.
  101. }
  102. /*
  103. #pragma mark - Navigation
  104. // In a storyboard-based application, you will often want to do a little preparation before navigation
  105. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  106. // Get the new view controller using [segue destinationViewController].
  107. // Pass the selected object to the new view controller.
  108. }
  109. */
  110. @end