// // GiGaBaseViewController.m // GIGA // // Created by lianxiang on 2018/8/13. // Copyright © 2018年 com.giga.ios. All rights reserved. // #import "GiGaBaseViewController.h" #import "UIView+Toast.h" #import "GiGaNavTitileView.h" #import "UINavigationBar+Custom.h" @interface GiGaBaseViewController () { } @end @implementation GiGaBaseViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; // Do any additional setup after loading the view. //[self.navigationController.navigationBar cnSetBackgroundColor:GIGARGB(216, 216, 216, 1)]; //[self.navigationController.navigationBar setBarTintColor:GIGA_MAIN_BGCOLOR]; } - (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController.navigationBar setBackgroundImage]; //[self.navigationController.navigationBar setTranslucent:YES]; } -(void)addNavTitile:(NSString *)title{ self.navigationItem.titleView = [[GiGaNavTitileView alloc] initWithString:title frame:CGRectMake(0, 0, 200, 44)]; } - (void)showNoNetWorkView { // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // if (self.currentNetworkStatus < 1) { // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // // }); // } // }); } - (void)removeNoNetWorkView{ if (_noNetWorkView) { [_noNetWorkView removeFromSuperview]; _noNetWorkView = nil; } } - (UIView *)noNetWorkView{ if (!_noNetWorkView) { _noNetWorkView = [GiGaNoNetWorkView new]; } return _noNetWorkView; } -(void)showEmptyView{ } - (void)removeEmtyView{ } -(void)testNetworkStatus{ AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager]; weakify(self); [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { weakSelf.currentNetworkStatus = status; if (weakSelf.network) weakSelf.network(status); switch (status) { case AFNetworkReachabilityStatusNotReachable: [[UIApplication sharedApplication].keyWindow makeToast:@"哎呀,没有网络啦~"duration:1.6 position:CSToastPositionCenter]; break; default: break; } }] ; //开始检测 [manager startMonitoring]; } //显示信息,并在设定延时后返回上级界面 - (void)backWithShowMessage:(NSString *)message afterDelay:(CGFloat)delay { [[UIApplication sharedApplication].keyWindow makeToast:message duration:1.6 position:CSToastPositionCenter]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self back]; }); } - (void)back { [self.navigationController popViewControllerAnimated:YES]; } -(UITableView*)tableView{ if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, PhoneX_TopMargin, KMainW,KMainH - PhoneX_BottomMargin) style:UITableViewStyleGrouped]; } return _tableView; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { return 0; } - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; } @end