IPhone - After dismissing Modal View Controller - gap is left at top of page(iPhone - 关闭模态视图控制器后 - 页面顶部留有间隙)
问题描述
启动应用程序时,如果用户没有存储登录信息,我想显示一个模式视图控制器来强制输入此信息.我通过反复试验发现,这必须发生在我的根视图控制器的 viewDidAppear 中.我试图将它放在 viewDidLoad 和 viewWillAppear 中,但除非我将根视图控制器的视图分配给模态中使用的导航控制器的视图,否则这些都不起作用,这会导致其他问题...
When starting the app, if the user doesn't have login information stored, I want to display a modal view controller to force the entry of this information. I found through trial and error, that this had to occur in viewDidAppear of my root view controller. I tried to put it in viewDidLoad and viewWillAppear, but those didn't work unless I assigned the view of the root view controller to the view of the navigation controller used in the modal which then caused other issues...
所以我有:
- (void)viewDidAppear:(BOOL)animated
{
NewAccountViewController *newAccountViewController = [[[NewAccountViewController alloc] initWithNibName:@"NewAccountViewController" bundle:nil] autorelease];
UINavigationController *accountNavigationController = [[UINavigationController alloc] initWithRootViewController:newAccountViewController];
[self presentModalViewController:accountNavigationController animated:YES];
}
在 newAccountViewController 中,我有一个简单的导航项按钮,可以使用dismissModalViewController 关闭模态视图控制器.
And in the newAccountViewController I have a simple navigation item button that dismisses the modal view controller with dismissModalViewController.
这一切都有效,当模式被关闭时,导航控制器中的视图可见,其导航项标题位于顶部....
This all works and when the modal is dismissed a view in a navigation controller is visible with its navigation item title at the top....
但是在状态栏和蓝色导航项栏的顶部之间有一个和状态栏差不多大小的白色间隙.如果我不做模态,那么差距永远不会存在.它仅在模态显示和关闭后发生.我试过在 present 和 dismissModalViewController 上做动画:NO.我也尝试过不在模态中使用导航控制器,但也没有用.任何想法都会很棒!谢谢.
But there is a white gap about the same size as the status bar between the status bar and the top of the blue navigation item bar. If I don't do the modal, then the gap is never there. It only occurs after the modal is presented and dismissed. I've tried doing animated:NO on both the present and dismissModalViewController. I've also tried not using the navigation controller in the modal, and that did nothing as well. Any ideas would be great! Thanks.
推荐答案
原来这是因为我在当前视图控制器上调用了我的 modalviewcontroller,但我的视图控制器已经有另一个视图控制器加载为子视图.一旦我将其更改为在子视图中创建视图控制器,加载模式,然后它就消失了.感谢您的所有帮助.
Turns out this was happening because I was calling my modalviewcontroller on the current view controller, but my view controller already had a another view controller loaded as a subview. Once I changed it to make the view controller in the subview, load the modal, then it went away. Thanks for all your help.
这篇关于iPhone - 关闭模态视图控制器后 - 页面顶部留有间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone - 关闭模态视图控制器后 - 页面顶部留有间隙
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01