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];
Related
I have a view controller, but when I hide the tab bar, there is just a black space where the tab bar was. I want to have my view controller sit behind the tab bar, so when I hide it, it shows the view content. I am using a simple UITabBarController. Thanks.
You can't do this, as far as I'm aware. The problem is that the view controllers sit within the tab bar controller, not the other way around.
The way to get around this would be to change the window view for a new navigation controller without a tab bar controller, or use a modal view to show content without a tab bar controller.
The problem is that your view on your view controller isn't tall enough to accommodate the space that your tab bar occupied.
CGRect current = [[self view] frame];
CGRect tabBarFrame = [[self tabBar] frame];
CGRect newFrame = CGRectMake(current.origin.x, current.origin.y, current.size.width, current.size.height + tabBarFrame.size.height);
[[self view] setFrame:newFrame];
Something like that is probably what you want. Or you can resize it in IB.
But, I don't know why you would use a UITabBarController and then hide the tab bar... If you can't see the tab bar, you cant switch tabs... thus making the UITabBarController pretty much just a UIViewController.
I believe that if you give the view property of your UIViewController a fixed bottom margin and a flexible height then it will stretch to fill the height of containing view automatically.
mycontroller.view.autoresizingMask = UIViewAutoresizingFlexibleHeight
I have a navigation bar based application, and at one specific point in the app I have a button on the nav bar that should present a new view using a flip transition (essentially taking a user from a tableview to a map view). I'm currently using
DetailLocationView *detailLocationView = [DetailLocationView alloc] init];
detailLocationView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.view presentModalViewController:detailLocationView animated:YES];
[detailLocationView release];
This code takes the entire view the user is in (navigation bar and table view) and flips it into just the detailLocationView. However, I would like for the detailLocationView to still have a navigation bar. I'm wondering what the best way to have the detailLocationView be loaded in so that it has a flip transition and is still has a navigation bar.
Thanks
pushViewController instead of presentModalViewController will retain the navbar, but will not as you want.
If you want to "flip" and still have the Navbar - you'd have to flip to a new view with the navbar. This is sort of illogical though, from a UI perspective - i.e. when you visually see the view flip - you're seeing it change to something completely different - so for the view to flip and then reveal the same navbar may be a bit confusing.
I have an application with a navigation bar and a tab bar. A user can navigate to a view which displays images in a scroll view. I'd like to have the same behavior as the iPhone photo app: Nav bar at the top, tool bar at the bottom, which will hide or show based upon a tap.
I'm moving my view to the window object in order to achieve full screen mode. This works fine:
myView = [self.view retain];
self.view = nil;
[window addSubview:myView];
But when I want to redisplay the Nav & tool bar, I run into a problem. The bars show fine, but the view is empty, and I can't seem to add any content to the view:
[myView removeFromSuperview];
self.view = myView;
I got a lot of good info from this post
but can't quite get the right combination.
By simply setting the controller's view, you aren't adding it as a subview to anything else, so it will never appear.
Moving views around like this can get a little tricky. I recommend that you not move the view from one to the other, but instead have two UIViews. Add second UIView to the window's subview and set it to hidden=YES initially. When you want to show it, set the image for the UIImageView, and then set the hidden property to NO.
what's wrong with just using setNavigationBarHidden: animated: and setToolbarHidden:animated:?
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.
My program has 4 buttons and each button calls a different table view. That works fine, but my problem is, the view controller I'm using brings up a table view that covers up my navigation bar and my tab bar. I need to replace that coding with something that will bring up a table and not cover up my nav and tab bars. Here is the coding I'm using:
-(IBAction)buttonNorthWest {
NorthWestViewController *nwController = [[NorthWestViewController alloc] initWithNibName:#"NorthWestView" bundle:nil];
self.nwViewController = nwController;
[self.view insertSubview:nwViewController.view atIndex:0];
[self presentModalViewController:nwViewController animated:YES];
[nwController release];
}
The [self presentModalViewController....] is the problem. Does anyone know how I can replace that code with something that keeps my nav and tab bars?
Thanks,
Jaime
On the iPhone, all modal view controllers must be full screen as seen here http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalPresentationStyle
As an alternative you could display the tableview as a subview and adjust the frame so that it does not overlap the nav or toolbar.