// // 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]; // Do any additional setup after loading the view. } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController.navigationBar cnSetBackgroundColor:GIGAUIColorFromRGB_A(0xD8D8D8, 0.2)]; } -(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)showEmptyView{ } -(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:self.view.bounds 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