【发布时间】:2014-04-09 15:35:15
【问题描述】:
以下是我自定义的VC演示代码:
-(void)presentViewController:(UIViewController*)vc
{
UIWindow *w = [[[UIApplication sharedApplication] delegate] window];
UIViewController *parentController = (TabBarViewController *)[w rootViewController];
[parentController addChildViewController:vc];
if ([vc respondsToSelector:@selector(beginAppearanceTransition:animated:)]) // iOS 6
{
[vc beginAppearanceTransition:YES animated:YES];
}
UIView *toView = vc.view;
[parentController.view addSubview:toView];
toView.frame = parentController.view.bounds;
CGAffineTransform tr = CGAffineTransformScale(self.view.transform, 1.0f, 1.0f);
toView.transform = CGAffineTransformScale(self.view.transform, 0.01f, 0.01f);;
CGPoint oldCenter = toView.center;
toView.center = ((RootViewControllerEx*)vc).cellCenter;
[UIView animateWithDuration:4.5 animations:^{
toView.transform = tr;
toView.center = oldCenter;
} completion:^(BOOL finished) {
[vc didMoveToParentViewController:parentController];
if ([vc respondsToSelector:@selector(endAppearanceTransition)]) // iOS 6
{
[vc endAppearanceTransition];
}
}];
}
它工作正常,但是,在提供的 VC 中,我隐藏了状态栏:
- (BOOL)prefersStatusBarHidden {
return YES;
}
当我使用内置的presentViewController:animated:completion: 展示我的 VC 时,展示的 VC 中的状态栏是隐藏的。但是我在 iOS 7 状态栏上的代码根本没有隐藏,在 iOS 6 上它更奇怪 - 状态栏是隐藏的,但我的视图大小比状态栏的大小从顶部变短。所以我可以在 iOS 6 上从顶部看到一个黑色间隙。使用自定义 VC 演示时,我应该如何正确隐藏状态栏?
【问题讨论】:
-
更新了代码以解决边界问题。它解决了 iOS 6 上的问题,但仍然可以看到 iOS 7 状态栏。
-
还尝试将
modalPresentationStyle设置为UIModalPresentationFullScreen。不好。
标签: ios uiview uiviewcontroller statusbar