1

I've been looking everywhere for a solution to this problem but can't seen to find one...

I have an UIImageView similar to facebooks where, if you tap the screen, image text and the UINavigationBar will show up. The problem is that the UINavigationBar pushes all the content down when appearing...

Is there a way to put this in a higher independent layer or something else that will make it not affect the rest of the view?

Thanks in advance.

2 Answers 2

0

I assume when the user taps the imageView, that its your code that's doing the pushing. What you should do is use UIViewController's 'presentViewController:' method. You have some options on how the animation will occur, and while this view will take over the screen, it will not get "pushed:" or appear to be "pushed". In this case the new view is controller by its own UIViewController subclass. [I use this technique.]

The other options is to look at UIView's '+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion' method, and rotate a new view into view. Your original view controller will then also control this view, you can do what you want, then when done the user taps something and you flip back to the original view. [I use this technique too].

EDIT:

The solution to your clarified problem in the comment is to set the property on the nav bar to transparent. On iPad now no Xcode handy but you'll see it in the class description.

2
  • Im not at home at the moment, but ill try and check in à couple of hours. :)
    – Tom
    Aug 25, 2012 at 13:36
  • I'm sorry for the bad explanation... With push I don't mean it like a segue, but more the figurative way of the whole views content getting moved in the y-direction to "make room" for the UINavigationBar. What I want is to simply make the UINavigationBar overlap the rest of the content instead.
    – Tom
    Aug 26, 2012 at 9:24
0

Since I couldn't find a way to make the content indifferent of whether the navigationbar was there or not, I simply moved up the content 22px (the default height of a UINavigationBar) when showing the bar. This solved my problem perfectly.

3
  • The default height of UINavigationBar is 44px in portrait and 32px in landscape mode. Jan 10, 2013 at 18:04
  • Perhaps he meant 44 pixels in terms of retina graphics design... 22 pixels in terms of moving it via code .center = CGPoint Nov 13, 2013 at 3:22
  • Hmmm well that's weird, for me it was 66px in portrait? Hahhaa... then again that's on an iPhone5? -(void)viewDidAppear:(BOOL)animated { theMainContentViewHolder.frame = CGRectMake(0, -66, theMainContentViewHolder.frame.size.width, theMainContentViewHolder.frame.size.height); } Nov 13, 2013 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.