tags:

views:

29

answers:

1

Hi all,

I am working with a project in which I have to have a login page and after successful login we should have a tabbar view( I am using tabbar controller) when I try to load the tabbar controller using the following code.Nothing works out.

LoginSuccess *viewController = [[LoginSuccess alloc] initWithNibName:@"LoginSuccess" bundle:nil]; [self.view addSubview:viewController.tabBarController.view]; [viewController release];

Can any one please help me.

A: 

i do same work but me call appdelegate after success of login response [mAppDelegate loadTabbar];//call function in delegate file to load tabbar view whom code is follow

pragma mark -

pragma mark Load TabBar

-(void)loadTabBar { self.tabBarController = [[UITabBarController alloc] init]; tabBarController.delegate = self;

MyAlarmVC *myAlarmVC = [[MyAlarmVC alloc] initWithNibName:@"MyAlarmVC" bundle:nil];
UINavigationController *myAlarmNVC = [[UINavigationController alloc] initWithRootViewController:myAlarmVC];
myAlarmNVC.navigationBar.tintColor = [UIColor whiteColor];
[myAlarmVC release];


MyVideosVC *myVideoVC = [[MyVideosVC alloc] initWithNibName:@"MyVideosVC" bundle:nil];
UINavigationController *myVideoNVC = [[UINavigationController alloc] initWithRootViewController:myVideoVC];
myVideoNVC.navigationBar.tintColor = [UIColor whiteColor];
[myVideoVC release];


MyFriendsVC *myFriendVC = [[MyFriendsVC alloc] initWithNibName:@"MyFriendsVC" bundle:nil];
UINavigationController *myFriendNVC = [[UINavigationController alloc] initWithRootViewController:myFriendVC];
myFriendNVC.navigationBar.tintColor = [UIColor whiteColor];
[myFriendVC release];


MyMessageVC *myMessageVC = [[MyMessageVC alloc] initWithNibName:@"MyMessageVC" bundle:nil];
UINavigationController *myMessageNVC = [[UINavigationController alloc] initWithRootViewController:myMessageVC];
myMessageNVC.navigationBar.tintColor = [UIColor whiteColor];
[myMessageVC release];

MyProfileVC *myProfileVC = [[MyProfileVC alloc] initWithNibName:@"MyProfileVC" bundle:nil];
UINavigationController *myProfileNVC = [[UINavigationController alloc] initWithRootViewController:myProfileVC];
myProfileNVC.navigationBar.tintColor = [UIColor whiteColor];
[myProfileVC release];

tabBarController.viewControllers = [NSArray arrayWithObjects:myAlarmNVC,myVideoNVC, myFriendNVC,myMessageNVC,myProfileNVC, nil];
[myAlarmNVC release];
[myVideoNVC release];
[myProfileNVC release];
[myFriendNVC release];
[myMessageNVC release];
[self.window addSubview:tabBarController.view ];
//tabBarController.navigationController.navigationBarHidden = YES;
[self.tabBarController release];

}

  • (void)tabBarController:(UITabBarController *)tabBarController1 didSelectViewController:(UIViewController *)viewController{

    NSArray *vc= tabBarController1.viewControllers;

    for (int i = 0; i < [vc count]; i++) {

    UINavigationController *nc = [vc objectAtIndex:i];
    
    
    if (nc == tabBarController1.selectedViewController) {
    
    
    
    continue;
    
    }

[nc popToRootViewControllerAnimated:NO]; }

}

if you got problem then just tell me the view names of your tabbar

GhostRider
This is what my appdelegate.h file has UIWindow *window; UIViewController *rootViewController; UITabBarController *loginTabbarController; Could you please explain why you are using navigation cpntroller. In my application I dont need a naviagtion controller. The views names I want to have in tabbar controller are Map,calender and record.
din
can you tell me the follow of your project so i can tell the proper code;
GhostRider
in above code me go to login screen and when me enter login button then call webservice it return response in success of false; if i go success then function loadtabbar is call which is declare in appdelegate
GhostRider
If you not want to add navigation controller then remove navigation controller lines just put view's object name tabBarController.viewControllers = [NSArray arrayWithObjects:myAlarmVC,myVideoVC, myFriendVC,myMessageVC,myProfileVC, nil];
GhostRider
This is the function I added to appdelegate.m
din
-(void) loadTabbar{ self.loginTabbarController = [[UITabBarController alloc] init]; loginTabbarController.delegate = self; loginTabbarController.viewControllers = [NSArray arrayWithObjects: Yard_Map, Calender, Summary, nil]; [self.window addSubview:loginTabbarController.view ];}
din
I get the following warning for [[UITabBarController alloc] init]; loginTabbarController.delegate = self; CLass does not implement UITabbarControllerDelegate protocol and a error for the next line saying expectedexpression before yard_map
din
loginTabbarcontroller is what I declared in appdelegate.h as UITabbarController. Can you let me about the function void)tabBarController:(UITabBarController *)tabBarController1 didSelectViewController:(UIViewController *)viewController
din
I could fix the error I said but not the warning. Could you help me with that.
din
not take care of that warning me also got warning that not make any effect on ur program
GhostRider