// // NotifySelectObjVC.m // LNManager // // Created by EchoShacolee on 2017/6/21. // Copyright © 2017年 lee. All rights reserved. // #import "NotifySelectObjVC.h" #import "Notify_SelectSchVC.h"//选择驾校 #import "Notify_SelectCityVC.h"//选择地市 #import "SendNotifyVC.h"//编写通知 @interface NotifySelectObjVC () { UITableView *_schTableView; UITableView *_cityTableView; UIScrollView *_mainScroolView; UISegmentedControl *_seg; NSString *_type;//类型 1 给管理部门 2 给驾校 } @end @implementation NotifySelectObjVC - (void)viewDidLoad { [super viewDidLoad]; [self myInit]; } -(void)myInit{ NSArray *titles = @[@"通知驾校",@"通知地市管理员"]; _seg = [[UISegmentedControl alloc]initWithItems:titles]; _seg.frame = CGRectMake(10, kNavOffSet, kSize.width-20, 40); _seg.tintColor = COLOR_THEME; _seg.backgroundColor = [UIColor whiteColor]; _seg.selectedSegmentIndex = 0; [_seg addTarget:self action:@selector(changeTableview:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:_seg]; _mainScroolView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 40+kNavOffSet, kSize.width, kSize.height-CGRectGetMaxY(_seg.frame))]; _mainScroolView.pagingEnabled = YES; _mainScroolView.bounces = NO; _mainScroolView.showsVerticalScrollIndicator = NO; _mainScroolView.showsHorizontalScrollIndicator = NO; _mainScroolView.delegate = self; _mainScroolView.contentSize = CGSizeMake(kSize.width*titles.count, 0); [self.view addSubview:_mainScroolView]; //驾校 Notify_SelectSchVC * vc = [[Notify_SelectSchVC alloc]init]; vc.type = 8; __weak typeof(self) weakSelf = self; vc.blcok = ^(NSArray *ids) { _type = @"2"; [weakSelf sendNotifyWithIDs:ids]; }; vc.view.frame = CGRectMake(0, 0, kSize.width, _mainScroolView.frame.size.height); [self addChildViewController:vc]; _schTableView = vc.tableView; _schTableView.frame = vc.view.frame; [_mainScroolView addSubview:vc.view]; //地市 Notify_SelectCityVC * city = [[Notify_SelectCityVC alloc]init]; city.blcok = ^(NSArray *ids) { _type = @"1"; [weakSelf sendNotifyWithIDs:ids]; }; city.goSchBlock = ^{ _seg.selectedSegmentIndex = 0; [_mainScroolView setContentOffset:CGPointMake(0, 0) animated:NO]; }; city.view.frame = CGRectMake(kSize.width, 0, kSize.width, _mainScroolView.frame.size.height); [self addChildViewController:city]; _cityTableView = city.tableView; _cityTableView.frame = CGRectMake(0, 0, city.view.frame.size.width, city.view.frame.size.height); [_mainScroolView addSubview:city.view]; } - (void)changeTableview:(UISegmentedControl *)sender{ // if (_schTableView.editing || _cityTableView.editing) { // return; // } [_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; } //-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{ // // if (_schTableView.editing || _cityTableView.editing) { // return; // } //} -(void)sendNotifyWithIDs:(NSArray *)ids{ SendNotifyVC * vc = [[SendNotifyVC alloc]init]; vc.ids = ids; vc.type = _type; [self.navigationController pushViewController:vc animated:YES]; } - (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