Modalviewcontroller在加载后显示间隙。 Gap是在staus bar之后移动modalviewcontroller并且gap显示我的主窗口。那么我如何消除状态栏和modalviewcontroller之间的差距。没有涉及的界面构建器。以编程方式创建所有内容。对此的帮助将非常感激。
UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight];
[button addTarget:self action:@selector(displayModalViewaction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] initWithCustomView:button];
- (void)displayModalViewaction: (id) sender
{
self.viewController = [[Infoviewcontroller alloc] init];
UINavigationController *navigationController=[[UINavigationController alloc] init];
navigationController.navigationBar.tintColor = [UIColor brownColor];
[navigationController pushViewController:_viewController animated:YES];
[self.view addSubview:navigationController.view];
}
由于
答案 0 :(得分:1)
在_viewController中,如果要隐藏间隙,则需要更新此代码 -
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
但理想情况下,需要通过 -
来修复 [self presentModalViewController:navigationController animated:YES];
不确定为什么它不适合你。
答案 1 :(得分:0)
假设此代码位于UIViewController中,您可能希望执行类似的操作。
self.viewController = [[[Infoviewcontroller alloc] init] autorelease];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
navigationController.navigationBar.tintColor = [UIColor brownColor];
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
答案 2 :(得分:0)
通过添加视图帧大小[self.view setFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];修正了状态栏和模态视图之间的差距。