0
votes

I need a login viewcontroller,when log in,entry the tabbar controller,and the view in tabbarcontroller should get the data from the login viewcontroller and change the navigationbar(draged from nib)'s title,for example,show the user's name.I did it like :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self.window addSubview:_tabbarController.view]; 
[self.window addSubview:_loginViewController.view];

[self.window makeKeyAndVisible];
return YES;}

I add two subview,so when I remove the loginviewcontroller,the root shows,in the LoginViewController.m,I did it like:

-(IBAction)ShangHaiButtonPressed:(id)sender{
    [self.view removeFromSuperview];}

so how do i pass the value in login view to my tabbarcontroller?

1

1 Answers

0
votes

Before remove from superview pass the value to tabbarcontroller

-(IBAction)ShangHaiButtonPressed:(id)sender{
     [_tabbarController setUsername: [_loginViewController username]];
     [_tabbarController setPassword: [_loginViewController password]];
     [self.view removeFromSuperview];
 }

I think it is not appropriate to remove the view directly. Why not use [_tabbarController presentModalViewController:_loginViewController]. and Dismiss it after button is pressed.