Is it possible to hide the Nav Bar on a UISplitViewController? - uikit

I have a very simple app that I want to use a UISplitViewController in. It's so simple that I don't want the NavigationBar visible in portrait because there is no navigation in the left pane. (I do want to show it in portrait for the Popover to appear from. However, I don't seem able to hide it. Is the top element even a Nav Bar?
I've tried both of these:
[[splitViewController navigationController] setNavigationBarHidden:YES animated:NO];
for(UIViewController* vc in [splitViewController viewControllers]) {
[[vc navigationController] setNavigationBarHidden:YES animated:NO];
}
But neither works.

you try this:
source code:
https://github.com/mattgemmell/MGSplitViewController/
it helpful for hide the nav bar on a SplitViewController

Related

Navigation bar turns solid black during push to new view controller

I have a UITableViewController embedded in a UINavigationController. Tapping a button pushes another view controller which has the navigation bar hidden. The issue is while the animation occurs, the navigation bar for the previous view turns a solid black.
Here's the best shot I could get. (The navigation bar is white by default)
http://imgur.com/fxU7VrS
Fixed by using
[self.navigationController setNavigationBarHidden:YES animated:YES];
instead of
self.navigationController.navigationBar.hidden = YES;

iOS7 Xcode utility app - UINavigationBar on Flipsideviewcontroller not spaced properly?

I have this issue, where as standard the flipsideviewcontroller UINavigationBar looks like this:
Anybody have any ideas on how to move the UINavigationBar either down, or to stop the ugliness of it all?
It's tricky. :) You need to set a delegate for the UINavigationBar - this will probably be the FlipsideViewController. You can do this in the storyboard, or in code - for example, if you have an outlet to the navigation bar:
-(void)viewDidLoad {
[super viewDidLoad];
self.navigationBar.delegate = self;
}
Now comes the important part: implement in the delegate this method:
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
return UIBarPositionTopAttached;
}
With auto layout, it is also crucial that the top of the navigation bar have a zero-constant constraint to the Top Layout Guide. This is not entirely easy to set up because there is a bug in Xcode that will try to turn this into a bad constraint from the bottom of the navigation bar. If that happens:
Delete the top constraint.
Move the nav bar down the screen.
Control-drag to form the top constraint to the Top Layout Guide again.
Now select the top constraint and manually set its Constant to 0, to make the nav bar move back up again.

Is there a way to enable the bottom toolbar in a Collection View Controller?

I made and implemented a collection view controller, and now I wish to add a bottom tool bar for navigation purposes. Under the Simulated Metrics tab in the Collection View Controller, I have enabled the bottom toolbar, and it shows up in the storyboard, and I am able to edit and interact with it.
When I run the app in the iPad simulator, the bottom toolbar does not appear. Is there some setting that I am missing that causes it to show in the storyboard and not in the app?
Any suggestions would be appreciated.
You can embed the UIViewController inside a UINavigationController. In the Storyboard, set the Simulated Metrics for Bottom Bar to one of the Toolbar options on the UINavigationController. You will then notice the Toolbar on the bottom of the UICollectionViewController.
I have done this using Xcode 6.3.2.
I had the same problem in Interface Builder.
Adding the toolbar programmatically works fine, though:
// viewWillAppear:
// set up toolbar
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height-44, self.view.bounds.size.width, 44)];
toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
[self.view addSubview:toolbar];
// instantiate spacer, middleItem
toolbar.items = #[spacer, middleItem, spacer];

Navigation Bar Layout Issue on Tab Bar Controller + Navigation Controller

I've followed a how-to to create a simple Tab bar controller with a navigation controller in the first tab. Until here all is working correctly, expect a strange issue on the layout.
When the app starts the first time, the Navigation Bar on the top of the first loaded nib is a little outside of the view. I cannot figure out why this happen. In the first view there is a button "Add new System" that opens a modal view. If I press this button and the modal view appears and then I dismiss the modal going back to the initial view, then the Navigation bar at the top is placed/refreshed correctly. The same happens if I press the second TAB (it's a simple nib without Navigation controller for now) and then back to the first TAB, the Navigation bar is placed in the correct position.
Here a screenshot on the first startup:
And here when I press the modal view or the second TAB and then back to the first view:
The code is quit simple following one of the numerous tutorials on the net. I'm NOT using storyboard. Only customization was adding the buttons on the top of the Navigation Bar:
UIImage *editbuttonImage = [UIImage imageNamed:#"edit_pressed.png"];
UIButton *editButton = [UIButton buttonWithType:UIButtonTypeCustom];
[editButton setBackgroundImage:editbuttonImage forState:UIControlStateNormal];
editButton.frame = CGRectMake(0, 0, editbuttonImage.size.width, editbuttonImage.size.height);
[editButton addTarget:self action:#selector(leaveEditMode)
forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithCustomView:editButton];
[editButton release];
[editbuttonImage release];
No other modifications were made. The nib was used before in a single view. Then I've tried to insert it into a TAB Controller + Navigation Controller.
I could post the whole code in case it's needed. Under Select System there is a Table View, in these pictures empty, also not shown.
Thank's for the help!
Simon
I've solved the issue myself. On startup I've setup to hide the status bar and shown it again in the app delegate. The directive used :
[[UIApplication sharedApplication] setStatusBarHidden:NO];
was after adding the navController as subview. Also the Navigation controller BAR was not out of the view, simply under the status bar.
Hope this helps someone :)
Cheers, Simon

How to add a bar button item in interface builder?

I am really new to iPhone development and I need help setting up my views.
I have a view that is named FirstViewController.xib and a controller class for this view.
In my MainWindox.xib I have setup a root controller with a moveToNextView function that is connected to the options bar button item.
So when I click on this item the current view switches to the first view and I am able to swticht back. That works fine so far.
The navigation bar at the top of the screen from the MainWindow.xib is displayed in the first view, too. But when I open FirstViewController.xib there isn't any navigation bar defined (but on build&run it is displayed).
This is a problem for me because I want to add a save bar item to the first view. How do I solve that?
Assuming you have a UIViewController (or UIViewController subclass) that is a child of a UINavigationController. Note, I'm using storyboards so your results may vary when using xibs.
If you do not see a UINavigationBar on the interface, try manually changing the simulated metrics.
Drag a Navigation Item onto the view (anywhere). You should now have a place to enter the title in the interface builder.
Now you can drag Bar Button Items onto the nav bar.
You have to do it from code. Add to your FirstViewController class viewDidLoad method:
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:#"Save" style:UIBarButtonItemStyleDone target:self action:#selector(doSave:)];
self.navigationItem.rightBarButtonItem = anotherButton;
[anotherButton release];
Just drag a bar button item onto your nav bar in Interface Builder. Xcode automatically wires it up then you can use it like anything else...

Resources