开发者

How can I switch from one UITabbarview controller to another UITabbarViewController in iPhone?

开发者 https://www.devze.com 2023-04-10 10:50 出处:网络
I have an UITabbarViewController with 3 tabbar items with a navigationbar. When I will press my first item of tabbar item there will be a button at the view.

I have an UITabbarViewController with 3 tabbar items with a navigationbar. When I will press my first item of tabbar item there will be a button at the view.

Now my question is when I will press the button, then it will go to the another tabbarview controller which have also 3 tabbar items. How can I do that?

UITabbarViewController[with navigation bar]--->tabaritem [1] + tabaritem [2] + tabaritem [3]

tabaritem [1] viewcontroller is taking a button when I will press button the another UITabbarcontroller will be shown at the screen.

开发者_如何学PythonUITabbarcontroller[2] [with navigation bar]--->tabaritem [1] + tabaritem [2] + tabaritem [3]

I am new to iPhone application development.

One more thing is that I can't use table view for two tabbarcontroller because my first tabbar item of first tabbar is taking a login page so when user will able to log in then he will see second tabbarviewcontroller.


Instead of swapping out the whole controller, why not just remove and add tab bar items for each of your modes? When your in your first mode, show tab bar items 1,2 and 3. If someone hits one, then remove all those items, and add items 4,5 and 6. Use the tag on the items to keep track of them.


The only way to do this, according to apples viewpoints, is to show one of the tab bars in a modal.

It seems like you're using the first Tabbarcontroller as a Login controller. In that case, you would have this as a Modalview over you're other (normal) Viewcontroller. On Application Start, you load the main tab controller.
You then check if the user is logged in and show the Model Logging Controller (which is a Tabbar controller again) if he isn't.
Once the user has successfully logged in, you just dismiss the Modal, and voila, you got the "main" tab controller visible.

[edit:] here's a short example in (Pseuod) code:
MainViewController.m:

-(void) viewWillAppear:(BOOL)anmiated 
 {  
   UIApplicationDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
   if (!appDelegate.isLoggedIn) {
      appDelegate.loginController = [[UIViewController alloc ] initFromNib:@"login"];
      [self presentModalViewController:appDelegate.loginController animated:NO];
   }

 }

in the LoginController

- (iBAction) loginClicked
  {
    [appDelegate.mainViewController dismissModalViewControllerAnimated:YES];
  }

This obviously assumes that you have references to your view controllers in the appdelegate.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号