A single view in my application refuses to populate the navigation bar in iOS7. I can see the bar is there, enabled, visible and transparent, because my scrollable controls float underneath it when I drag them up. The issue is simply that when I add controls to self.navigationItem.leftBarButtonItem / self.navigationItem.rightBarButtonItem, and denote the title of the view (in the ViewController) with self.title = #"Title"; they do not show in the navigation area.
The strange thing is if I set self.navigationController.navigationBar.topItem.title = #"Title", this renders a title on the view in the navigation bar (but is not a solution as it causes problems when navigating elsewhere in the app). The expression "(self.navigationController.navigationBar.topItem != self.navigationItem)" evaluates true, and I do not understand how this can be the case.
There are other views in the application which render navigation controls properly with the statements shown above.
I should mention that this application performs as expected under iOS6.1. I am pretty new to iPhone dev, so could easily have missed something. Any suggestions for what I could check will be appreciated.
Solved. I was using an incorrect method of pushing the view controller into the navigation controller.
Instead of
self.navigationController.viewControllers = [NSArray arrayWithObject:self.myViewController];
Use the following
[self.navigationController pushViewController:self.vehicleListViewController animated:YES];
Related
I recently started using interface builder, the problem i'm facing right now is when i use the back button of navigation controller, my UI elements' y axis go up by roughly 20-30 px, is there some setting i've to use to avoid this problem ? And they go up only when i use pushViewController, when i use popViewController it loads the way i need.
Code i'm using for pushing:
examVC=[[ExampleClass alloc] initWithNibName:#"ExampleClass" bundle:nil];
[[self navigationController] pushViewController:examVC animated:YES];
I'm attaching the images with the question. Please note how label has gone down about 20-30 px.
Why does this happen? What am i doing wrong ?
Thanks for all the help.
Edit : changed the screens for better clarity
I'm using pushing code on the round rect button.
Screen 1:UI elements set in my IB
Screen 2: How it looks when pushed from previous view
Screen 3: How it looks when popped from the "Next View"
My home view controller had the navigation bar hidden, the screen i posted was the second view which comes after the home view. I wanted to hide navigation bar in the first view only, so i had used :
- (void)viewDidDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewDidDisappear:animated];
}
It caused the problem because i was showing the navigation bar again in viewDidDisappear, so the view would load first then the navigation bar would be shown causing it to overlap.
So i put the same code in viewWillDisappear, which removed the issue. As navigation bar did load before loading of the next view. Now the view loads just like i designed it in interface builder.
Hey I don't know whether it will work for you or not but in your IB change top bar None to Navigation Bar
Then adjust your element accordingly and tun the code.
I tried all of the suggestions here and none of them worked. My UI elements were always lower when popping back to my original view controller. The only thing that fixed this for me was going into my nib file in Interface Builder and turning off Auto Layout.
I want to hide the bottom toolbar on a certain screen in my application, and IB seems to have an option for that which seems to preview as working correctly, but when I build and test the application the bottom toolbar is still there.
I know that I can use [self.navigationController setToolbarHidden:YES]; but my question is not how to do it using code, but how to get this to work through Interface Builder.
Here is a screenshot of what I am talking about. See on the right how I have selected Bottom Bar: None - this removes the bottom bar as previewed to the left. If I set it to inferred (instead of None) the bottom bar shows in the IB preview.
How do I get this to work correctly?
You can't set this in Interface Builder. If you notice the header of the section in IB where you can turn on/off these different bars, it says "simulated". These options are only there to help you visualize your UI in IB while designing it. They have absolutely no influence on the running app.
I couldn't do it in storyboard when you just want to hide toolbar in one view controller. If you want to hide it for all, you need to go to the navigation controller, and set the values in the storyboard. But this makes all of your view controllers to hide the toolbars. If you want to hide it for one view controller use this in that view controller:
-(void) viewWillAppear:(BOOL)animated
{
[self.navigationController.toolbar setHidden: YES];
}
-(void) viewWillDisappear:(BOOL)animated
{
[self.navigationController.toolbar setHidden: NO];
}
Enable "Hides Bottom Bar on Push" within the IB in case your ViewController is pushed onto a UINavigationController stack.
This should exactly do what you are asking for. As a bonus, the hiding and showing will be nicely animated by the system.
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 tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.
How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.
Had this issue and fixed it with a class that inherited from UINavigationController
-(void)viewWillAppear:(BOOL)animated
{
self.navigationBar.translucent = YES;
}
Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];
this seemed to do the trick for me!
I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder
I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)
In my application, the view below navigation controller moves up and is visible below the navigation bar as it's becoming transperant after adding a barbuttonitem programmatically to the navigation controller which I'm adding to view through an xib.
This' the way I'm adding it:
UIBarButtonItem *comment = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
target:self
action:#selector(buttonPressed)];
self.navigationItem.rightBarButtonItem = comment;
EDIT:
Ok, I quite came to know that this' happening because for all my custom cells of different type except one, I'm pushing xib files of detailedviews to navigation controller for tapped cells, but for this only one, I've created a view controller programmatically and pushing it. So as long as I don't tap and open this cell in detailview, everything works fine, but after I open this cell's detailview(which always opens fine), other cells detailviews shift.
Can anybody please address this issue?
Thanx in advance.
Check all view's frame and for testing set different color for all subviews.You will find out the problem easily. or post more detailed code.
Difference in size of viewControllers view:
If you are creating it through .XIB, then you will be having status bar in it. means your view size is 20 pixels lesser than that of the window. (320 * 460)
If you are creating it programmatically, then there will not be a status bar. Means size will be 320*480.
In this way view frame differs...
So set the size of view to 320*460 and try out...
Ok, after lot of struggling, I figured it out that what causes the problem is that since I'm using Three20 library to show facebook-like photos, the TTPhotoviewcontorller in it changes the bar style of the navigation bar of your navigation controller to UIBarStyleBlackTranslucent, and what you need to do is to reset the bar style property to UIBarStyleDefault. You should try to call
self.navigationController.navigationBar.bar = UIBarStyleDefault;