| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- //
- // RootViewController.m
- // Apex Mobile
- //
- // Created by Ray on 25/01/2018.
- // Copyright © 2018 United Software Applications, Inc. All rights reserved.
- //
- #import "RootViewController.h"
- @interface RootViewController ()
- @end
- @implementation RootViewController
- - (UITabBarItem *)itemWithSelectedImage:(NSString *)selectImage image:(NSString *)image title:(NSString *)title{
- UIImage *im = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:title image:im selectedImage:im];
-
- return item;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self registForNotification];
-
- self.automaticallyAdjustsScrollViewInsets = NO;
- // self.navigationItem.navi
- // [self.navigationController setNavigationBarHidden:YES animated:YES];
-
- // [UIStoryboard storyboardWithName:@"EnumSelectAndSort" bundle:nil]
-
- UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
- backItem.title = @"Back";
- self.navigationItem.backBarButtonItem = backItem;
-
- AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-
- LoginViewController * loginVC = [ [UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginPanel"];
- loginVC.loginSuccessful = ^(void)
- {
- appDelegate.isLogin = YES;
- appDelegate.shouldCheckCache = YES;
- // 登陆成功后重新刷新tabbar
- self.viewControllers = self.loginbar;
- };
- // loginVC.tabBarItem = [self itemWithSelectedImage:@"login" image:@"login" title:@"login"];
- // ToolslistViewController* toolVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ToolsPanel"];
-
-
- ToolslistViewController *toolVC=[[ToolslistViewController alloc] initWithNibName:@"StaticModelistViewController" bundle:nil];
-
- HomeViewController* homeVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HomePanel"];
-
-
- SearchlistViewController* searchVC = [[SearchlistViewController alloc] initWithNibName:@"StaticModelistViewController" bundle:nil];
- //[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"SearchPanel"];
- MylistViewController* myVC = [[MylistViewController alloc] initWithNibName:@"StaticModelistViewController" bundle:nil];
-
- myVC.logoutSuccessful = ^(void)
- {
- appDelegate.isLogin = NO;
- // 登陆成功后重新刷新tabbar
- self.viewControllers = self.logoutbar;
- };
- //[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"MyPanel"];
- OrderHistoryViewController* historyVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HistoryPanel"];
- // toolVC.tabBarItem = [self itemWithSelectedImage:@"tools" image:@"tools" title:@"tools"];
- // Do any additional setup after loading the view.
-
-
- self.logoutbar = @[loginVC,toolVC];
- self.loginbar = @[homeVC,historyVC,searchVC,toolVC,myVC];
- self.viewControllers = self.logoutbar;
-
-
- // tabbar 选中色
- self.tabBar.tintColor = [UIColor colorWithRed:168 / 255.0 green:9 / 255.0 blue:26 / 255.0 alpha:1.0];
- // self.tabBar.tintColor = [UIColor blueColor];
- // self.tabBar.barTintColor = [UIColor blackColor];
-
- }
- - (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.
- }
- */
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)registForNotification {
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:NotificationTypeLogout object:nil];
-
- }
- - (void)handleNotification:(NSNotification *)notification {
-
- AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- if ([notification.name isEqualToString:NotificationTypeLogout]) {
-
- [appDelegate Logout];
- [(LoginViewController *)self.logoutbar.firstObject clear];
- self.viewControllers = self.logoutbar;
- self.selectedIndex = 0;
-
- }
- }
- @end
|