iOS 登录页面跳转到首页(含有tabBar)

自定义tabBar类

 

在customTabBarCtrl.h中

#import <UIKit/UIKit.h>
 
@interface customTabBarCtrl : UITabBarController

@end

在customTabBarCtrl.m中

#import "customTabBarCtrl.h"
#import "mainViewController.h"
#import "loveViewController.h"
#import "mineViewController.h"
 
@implementation customTabBarCtrl
 
- (void)viewDidLoad {
    [super viewDidLoad];
    [self dismissViewControllerAnimated:NO completion: nil];

    UINavigationController *nav;
    UIViewController *mainVC = [[mainViewController alloc]init];
    nav = [[UINavigationController alloc] initWithRootViewController: mainVC];
    nav.tabBarItem.image = [UIImage imageNamed:@"首页-灰色.png"];
    nav.tabBarItem.selectedImage = [UIImage imageNamed:@"首页-绿色.png"];
    nav.tabBarItem.title = @"首页";
    [self addChildViewController: nav];
 
    UIViewController* loveVC = [[loveViewController alloc] init];
    nav = [[UINavigationController alloc] initWithRootViewController: loveVC];
    nav.tabBarItem.image = [UIImage imageNamed:@"爱心-灰色.png"];
    nav.tabBarItem.selectedImage = [UIImage imageNamed:@"爱心-绿.png"];
    nav.tabBarItem.title = @"爱心";
    [self addChildViewController: nav];
 
    UIViewController* VC3 = [[UIViewController alloc] init];
    nav = [[UINavigationController alloc] initWithRootViewController: VC3];
    nav.tabBarItem.image = [UIImage imageNamed:@"亲情-灰色.png"];
    nav.tabBarItem.selectedImage = [UIImage imageNamed:@"亲情-绿色.png"];
    nav.tabBarItem.title = @"亲情";
    [self addChildViewController: nav];
    UIViewController* mineVC = [[mineViewController alloc] init];
    nav = [[UINavigationController alloc] initWithRootViewController: mineVC];
    nav.tabBarItem.image = [UIImage imageNamed:@"我的-灰色.png"];
    nav.tabBarItem.selectedImage = [UIImage imageNamed:@"我的-绿色.png"];
    nav.tabBarItem.title = @"我的";
    [self addChildViewController: nav];
}

-(void)viewWillAppear:(BOOL)animated {
    self.navigationController.navigationBarHidden = YES;
}

在登录页面中,点击登录跳转的方法中执行下面代码

UITabBarController *tabBarCtrl = [[customTabBarCtrl alloc]init];
[self presentViewController:tabBarCtrl animated:NO completion:nil];

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值