Removing TabBar Controller when UIBar Button Clicked

拟墨画扇 提交于 2019-12-08 13:02:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!