之后dismissModalViewControllerAnimated:我的标签栏消失 [英] After dismissModalViewControllerAnimated: my tabbar disappears
问题描述
我有一个由三层视图控制器组成的应用程序:UITabBarController => UINavigationController => UIViewController。它们都是在代码中生成的,而不是使用IB。按照通常的设计指南,选项卡栏位于底部。在我的UIViewController我使用这个代码来呈现modalViewController:
myModalVC = [[MyModalViewController alloc] init];
[self.navigationController presentModalViewController:myModalVC animated:YES];
这个工作很好,模态视图控制器弹出并覆盖整个屏幕。
$然而,当在模态视图控制器中按下按钮时,我运行这个: [self dismissModalViewControllerAnimated:YES];
模态视图控制器动画。但是我可以看到原始的UIViewcontroller视图,但标签栏完全消失。我已经google了很多,但我找不到任何人有同样的问题。
实际上,我通过googling多了一点。我使我的标签栏控制器是应用程序委托的属性,当它提供模态vc时,它会这样
UIApplication * myApp = [UIApplication sharedApplication];
noIBAppDelegate * appDelegate =(noIBAppDelegate *)myApp.delegate;
[appDelegate.tabBarController presentModalViewController:myModalVC animated:YES];
UIApplication * myApp = [UIApplication sharedApplication];
noIBAppDelegate * appDelegate =(noIBAppDelegate *)myApp.delegate;
[appDelegate.tabBarController dismissModalViewControllerAnimated:YES];
这将修复标签栏消失。
I have an app which consists of three layers of view controllers: UITabBarController => UINavigationController => UIViewController. They are all generated in code rather than using IB. The tab bar is on the bottom as per the usual design guidelines. In my UIViewController I am using this code to present the modalViewController:
myModalVC = [[MyModalViewController alloc] init];
[self.navigationController presentModalViewController:myModalVC animated:YES];
This work fine and the modal view controller pops up and covers the entire screen.
However when a button is pressed within the modal view controller, I run this:
[self dismissModalViewControllerAnimated:YES];
And the modal view controller animates away. However I can see the original UIViewcontroller view but the tab bar disappears completely. I've googled a lot but I can't find anyone that has this same problem.
Actually I found this by googling a bit more. I made my tab bar controller a property of the app delegate and when it presents the modal vc, it does this
UIApplication *myApp = [UIApplication sharedApplication];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate.tabBarController presentModalViewController:myModalVC animated:YES];
Then it dismisses it by this bit of code
UIApplication *myApp = [UIApplication sharedApplication];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate.tabBarController dismissModalViewControllerAnimated:YES];
This fixes the the tab bar disappearing.
这篇关于之后dismissModalViewControllerAnimated:我的标签栏消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!