I have a navigation view controller and I want a subview ( just a view and not a view controller) to slide on top of it when a button in the parent view is clicked. Now, the thing is when I do this:
[parentView addSubview:slideView];
[UIView beginAnimations]
//setting the frame for sliding
[UIView CommitAnimations]
the sliding view goes under the navigation bar after sliding. I would like it to slide on top of the navigation bar of the parent view. How do I achieve this?
Essentially, all I am trying to do is: replicate the iPhone Add Contact application with the only difference being; unlike me, they don't have a navigation controller on the parentView but just a navigation bar with a system add button.
Anyone!!
if you use:
[self.navigationController presentModalViewController:view];
that will slide up a view (I think) over the navigation bar.
You have to add the view (which should be over the navigation bar) as a subview to the navigation bar.
Related
I have a typical ios app with a navigationcontroller. The navigation bar on the top has left and right buttons that stay the same through different views, so I would like to animate just the current view and not the top bar.
I'm not sure how to get started with this.
I've got an idea.
First, add your custom navigation bar on the top of the main view.
Second, add a navigationController as a subview under your navigation bar.
Now if the navigationController do the pushing or popping, your navigation bar will not change at all.
I have an application where I'm trying to duplicate what I see the Apple Store app doing, where the first view doesn't have a navigation bar, but subsequent views do.
I've tried various combinations of setting navigationBarHidden to YES and NO to manage when it's visible, but the key problem seems to be that during the transition, it's either visible or it isn't, whereas in the Apple Store app, the navigation bar is not there in the main view, but slides in from the right with the child view.
What I'm looking for is a way to have the navigation bar slide in with the child view, not appear (animated or not) before or after the transition.
Turns out I just hadn't hit on the right places to hide and show the navigation bar.
I used the answer from how to hide navigationbar when i push from navigation controller? and it works great for me now.
in your main view, initialize the childViewController. Then set the nav bar on the childViewController, the push the view controller.
ChildVC *childVC = [[ChildVC alloc] initWithNibName:#"ChildVC" bundle:nil];
[self setChildVC:childVC];
childVC.navigationController.navigationBarHidden = NO;
[self.navigationController pushViewController:childVC animated:YES];
If you are talking about what they do on the first Tab "Featured", where if you tap one of the items in the list with a disclosure indicator. It appears to slides in another view from right to left. I think they are using an animation to swap two view controllers. The one that slides in IS a Navigation controller which is why NavBar appears to slide in from the right.
You would do something like this to get that effect:
// First set up a view controller with frame set off to the right of the screen.
// Then animate it sliding to the left by setting its frame x = 0;
frame.origin.x = 0;
[UIView animateWithDuration:.4 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
animations:^{
vc.view.frame = frame;
}
completion:nil];
I have a viewController pushed in navigationController.
When this viewController pushed, the navigation bar was attached on top(0.0, 0.0), and
the viewController's view was attached just under that. (maybe.. 0.0, 44.0)
But, I want this view to locate to (0.0, 0.0) with navigation bar.
Namely, the top side of the view have to be covered beneath the navigation bar.
Thank you for your reading.
To achieve this apple has provided barStyle and translucent properties for navigationBar. It will reduce navigation bar's opacity and will start your viewcontroller from statusBar. It will look like what we see in Photo app.
In this case your view controller will be partially visible (as alpha for navigation bar will become < 1). I don't know whether this solves your purpose or not.
https://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html
Thanks,
When you show your view controller, do this on the navigation controller.
[navController setNavigationBarHidden:YES];
It will hide the navigation bar and the view controller will be all the way to the top.
Is there a way to present a modal view controller that doesn't cover the tab bar of a UITabBarController?
Specifically I want to use the UIModalTransitionStylePartialCurl, but preserve the bottom bar, a la the iPhone maps app.
Have two view controllers
In the first have the second as a subview
Add your toolbar as a subview to the first and call bringSubviewToFront:
Present the modal in the second
UIModalTransitionStylePartialCurl
When the view controller is presented,
one corner of the current view curls
up to reveal the modal view
underneath. On dismissal, the curled
up page unfurls itself back on top of
the modal view. A modal view presented
using this transition is itself
prevented from presenting any
additional modal views.
And
hidesBottomBarWhenPushed A
Boolean value indicating whether the
bar at the bottom of the screen is
hidden when the view controller is
pushed on to a navigation controller.
#property(nonatomic) BOOL
hidesBottomBarWhenPushed
Discussion
If
YES, the bar at the bottom of the
screen is hidden; otherwise, NO. If
YES, the bottom bar remains hidden
until the view controller is popped
from the stack.
There are discussions around this topic on stackoverflow in the past
What is the cleanest way to set up a structure where you have an initial standard, full screen UIView, which transitions to a Tab Bar view?
Add the tab bar view as a subview to the window. Then show the fullscreen view (controller) by presenting it as a modal view (controller) over the tab bar. Remove the fullscreen view with an animation by dismissing the modal view.
Yes, I agree. Displaying ordinary UIView over a UITabBarController view as modal is probably the cleanest way. But you could alternatively do a flip view transition if you don't want to use modal view.