views:

1635

answers:

2

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.

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

Below is how I am positioning the view


//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!

A: 

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!

AJ
A: 

There appears to be some special handling inside UIScrollView when the navigation toolbars are toggled. As you pointed out at the end of your question, if you put the scroll view inside a containing UIView, this repositioning problem does not occur.

To fix the landscape issues, make sure you're setting the autoresizingMask on both the container view and the scroll view. I did not have to add any additional handling for landscape mode in my project.

Steve Madsen