// // IfishMianTabViewController.m // ifishTabTest // // Created by imac on 16/7/25. // Copyright © 2016年 xiang. All rights reserved. // #import "IfishMianTabViewController.h" #import "AppDelegate.h" #import "NTESSessionListViewController.h" #import "NTESContactViewController.h" #import #import "UIImage+NTESColor.h" #import "NTESCustomNotificationDB.h" //#import "NTESNotificationCenter.h" #import "UINavigationBar+Background.h" #import "NTESBundleSetting.h" #import "IfishStartAdView.h" #import "IfishUserDefaultHelper.h" #import "IfishUserObsever.h" #import "UITabBar+addRedPointBadge.h" #import "LoveFishLiveListBaseViewController.h" @interface IfishMianTabViewController () @property (nonatomic,strong) NSArray *navigationHandlers; @property (nonatomic,assign) NSInteger sessionUnreadCount; @property (nonatomic,assign) NSInteger systemUnreadCount; @property (nonatomic,assign) NSInteger customSystemUnreadCount; @property (nonatomic,copy) NSDictionary *configs; @property (nonatomic,strong) UINavigationController *meassageNavVC; @end extern BOOL launchedByNotification; @implementation IfishMianTabViewController + (instancetype)instance{ AppDelegate *delegete = (AppDelegate *)[UIApplication sharedApplication].delegate; UIViewController *vc = delegete.window.rootViewController; if ([vc isKindOfClass:[IfishMianTabViewController class]]) { return (IfishMianTabViewController *)vc; }else{ return nil; } } -(instancetype)init{ self = [super init]; if (self) { [self creatViewControllers]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //[self creatViewControllers]; //[self setUpSubNav]; self.tabBar.translucent = NO; [[NIMSDK sharedSDK].systemNotificationManager addDelegate:self]; [[NIMSDK sharedSDK].conversationManager addDelegate:self]; extern NSString *NTESCustomNotificationCountChanged; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onCustomNotifyChanged:) name:NTESCustomNotificationCountChanged object:nil]; static dispatch_once_t disOnceAdview; dispatch_once(&disOnceAdview, ^ { BOOL show = [IfishUserDefaultHelper digShowAdview]; if (show) { return ; } //首页弹窗 //[self showAdview]; }); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imLogInnotifiy) name:IFISHIMLOGINSUCSESS object:nil]; } -(void)imLogInnotifiy{ //原来消息在tab 登陆界面进来时 显示badge 消息栏 消息数 UI已改暂时不需要了 如以后改回来 登陆显示badge在此处理 打开下面 //NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount]; //count ==0 ? (self.viewControllers[1].tabBarItem.badgeValue =nil):(self.viewControllers[1].tabBarItem.badgeValue = [NSString stringWithFormat:@"%ld",(long)count]); } -(void)showAdview{ IfishStartAdView *adview=[[IfishStartAdView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; adview.delegate = self; [self.view addSubview:adview]; } #pragma mark- HomeStartAdviewDelegate -(void)goButtonAction{ [IfishUserDefaultHelper showAdview:YES]; [self setSelectedIndex:2]; [self performSelector:@selector(homeAdViewAction) withObject:self afterDelay:1]; } -(void)homeAdViewAction { [[NSNotificationCenter defaultCenter] postNotificationName:@"homeAdViewAction" object:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)creatViewControllers{ // NTESSessionListViewController // 旧 // NSArray*VCArr=@[@"IfishDeviceViewController", // @"IfishMessageViewController", // @"IfishDiscoverViewController", // @"IfishMeViewController"]; // 新v4.3前 消息在tab栏上 //NSArray*VCArr=@[@"IfishDeviceViewController", // @"NTESSessionListViewController", // @"IfishDiscoverViewController", // @"IfishMeViewController"]; //消息在首页导航上 NSArray*VCArr=@[@"IfishDeviceViewController", @"LoveFishLiveListBaseViewController", @"IfishDiscoverViewController", @"IfishMeViewController"]; NSArray *titles=@[@"首页",@"爱鱼看看",@"探索",@"我的"]; NSArray *ImageArr=@[@"ifish_facility_off", @"ifish_look_off", @"ifish_discovery_off", @"ifish_me_off"]; NSArray *selectImageArr=@[@"ifish_facility_on", @"ifish_look_on", @"ifish_discovery_on", @"ifish_me_on"]; NSMutableArray *VCArr1=[[NSMutableArray alloc]init]; for (NSInteger i=0; i