您的位置:首页 > 其它

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

2015-09-07 15:20 330 查看
自定义tabBar类

在customTabBarCtrl.h中

<span style="font-size:14px;">#import <UIKit/UIKit.h>

@interface customTabBarCtrl : UITabBarController

@end</span>


在customTabBarCtrl.m中

<span style="font-size:14px;">#import "customTabBarCtrl.h"
#import "mainViewController.h"
#import "loveViewController.h"
#import "mineViewController.h"

@implementation customTabBarCtrl

- (void)viewDidLoad{
[super viewDidLoad];
[self dismissViewControllerAnimated:NO completion: nil];</span>


<span style="font-size:14px;">  UINavigationController *nav;</span>
<span style="font-size:14px;">  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];</span>


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


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

<span style="font-size:14px;">UITabBarController *tabBarCtrl = [[customTabBarCtrl alloc]init];
[self presentViewController:tabBarCtrl animated:NO completion:nil];</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: