问题
In my Application first i have some Login View Controller,after login with button action am moving to Tabbar Controller with Four tabs. my problem is i need to quit that tabbar controller when i click on barbutton and need to come to that loginViewController.please anybody help me in this.actually i have tried some methods but i dint get that. Thanks in Advance for Valuable Solution to problem.
回答1:
In appDelegate place your tabBar and in side loginView ,add this tabBar
TUTAppDelegate *appdelegte =(TUTAppDelegate*)[[UIApplication sharedApplication]delegate];
[[appdelegte window]addSubview:[[appdelegte motivationalTabBar]view]];
On button press remove TabBar
TUTAppDelegate *appDelegate = (TUTAppDelegate *)[[UIApplication sharedApplication] delegate];
[[[appDelegate motivationalTabBar] view]removeFromSuperview]
回答2:
Add your tabBar controller to [appdelegte window] first and then present Login View Controller on it. When user log-ins successfully, dismiss Login View Controller. Again when you click on barbutton to come to that loginViewController , present Login View Controller on tabBar controller. In this case there is no need to add and remove tabBar again and again.
回答3:
AppDelegate *delegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
[delegate.tabBarController.view removeFromSuperview];
[delegate.window addSubview:delegate.loginViewController.view];
i got solution for my problem with this code. hope this will help for someone.
thanks for all answers.
来源:https://stackoverflow.com/questions/12316331/removing-tabbar-controller-when-uibar-button-clicked