UIScrollView在导航和状态栏下方移动 [英] UIScrollView shifts below navigation and status bar

查看:392
本文介绍了UIScrollView在导航和状态栏下方移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含scrollView的视图.当视图显示时,图像以全屏(320x480)出现,并隐藏状态和导航栏.当我点击屏幕时-屏幕上会显示状态和导航栏.但是,这会将UIScrollView移到导航栏下方.我希望状态和导航栏显示在我的滚动视图上.

I have view which contains a scrollView. When the view shows up the image appears in full screen (320x480) hiding the status and navigation bar. When I tap the screens - status and navigation bar appears on the screen. But this thing shifts the UIScrollView below the the navigation bar. I want the status and nav bar to show over my scroll view.

就像在照片应用中一样.点击图像时,状态和导航栏将显示在scrollView上.

Like it happens in the photos app. On tapping the image the status and nav bar shows over the scrollView.

下面是我如何定位视图


//What I have done in viewDidLoad
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
self.wantsFullScreenLayout = YES;
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view = scrollView;

下面是我在检测单击时要做的事情

Below is what I am doing on detecting a single tap


- (void)tapDetectingImageView:(TapDetectingImageView *)view             gotSingleTapAtPoint:(CGPoint)tapPoint {
    // single tap hide/unhide the status and nav bar
    NSLog(@"got a single tap");
    if (self.navigationController.navigationBarHidden == NO)
    {

        [self.navigationController setNavigationBarHidden:YES animated:NO];
        [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
    }
    else
    {
        [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
        [self.navigationController setNavigationBarHidden:NO animated:NO];
    }
}

只是给你们的指针- 如果使用

Just a pointer for you guys - If I use

[self.view addSubview:scrollView];

,则看不到此问题.但这弄乱了我的横向代码.

I dont see this issue. But this mess up my landscape orientation code.

任何可以阐明我可能在做错事情的人-都会很有帮助!

Anyone who can shed some light what I might be doing wrong - would be great help!

推荐答案

我自己找到了解决方案. 在我的点击检测代码的else fn中,在最后一行添加以下行.

I found the solution myself. In my tap detecting code's else fn I add the below line in the last.

scrollView.contentOffset = CGPointMake(parentScrollView.contentOffset.x,0);

不确定这是否是正确的方法.但是,如果有人可以提出更好的方法,那就比欢迎了!

Not sure if this is the right approach. But if anyone can suggest a better approach - more than welcome!

这篇关于UIScrollView在导航和状态栏下方移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆