I got a tabbar application.
There is only 2 tabs in the tabbar. First tab is a NavigationController, second is a TableViewController. Second works perfect, but the the first doesn't.
When i start application, i saw black window. And there is not title on the NavigationBar.
self.navigationBar.topItem.title = #"Routes";
What's the problem? Thnx.
Well, you haven't pushed a view controller to your navigation controller yet. A navigation controller is just a container for another UIViewController.
Do something like this:
- (void)viewDidLoad {
[super viewDidLoad]
// Initialize an UIViewController here ...
[self pushViewController:myRootViewController animated:NO];
}
Related
Currently I have a UIViewController with a couple of buttons that when pressed move to a UITableViewController. Each button loads a specific array of data to the UITableViewController by identifying the segue of the specific button and displaying the corresponding data.
This works fine as is.
However I wish to add an embedded UINavigationController so I can navigate through the UITableViewController and and corresponding views while still being able to 'press back' to the initial UIViewController.
Firstly, where am I meant to put this. I tried over the tableViewController and 2 things happen -
a) If the segues still go to the UITableViewController, there is no navigation displayed.
b) If I move the segues to go to the UINavigationController, none of my arrays show in the tableViewController, but I do have navigation.
Where do I link my segues or where do I embed the UINavigationController so this works?
(I haven't put any code as I don't think this will involve it, but if it does just let me know and I will add).
Not sure if I'm missing something but, it's not working. I want to be able to still utilize the buttons I already have and not use the buttons on the navigation from the UIViewController to the UITableViewController.
For Hiding the Navigation on root
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
The ViewController which has 2 buttons can be made as rootViewController to the NavigationController. The NavigationController can be added to the window.
Window -> NavigationController -> UIViewController (as rootView)
Hope this helps.
Select the root view controller->editor->embed in->navigation controller
Any ideas on how to add a Navigation Controller in iOS7 between a Table View and View Controller?
As soon as I embed the Navigation Controller to the table view the app crashes.
Without the Navigation Controller it works fine. But then the Table View becomes a View Controller. This is the code I'm using:
[self.navigationController performSegueWithIdentifier:#"setup" sender:self];
Here is my storyboard: http://sv.tinypic.com/r/1ztdnb/8
Okay, giving the comments here is what I think you want:
A LoginViewController which is a subclass of a UITableViewController. Should not display navigationBar.
A ProfileViewController also a subclass of a UITableViewController. Should display a navigationBar.
When a user taps LogIn button, ProfileViewController should be "pushed".
So the whole trick is to make navigation bar hidden for one view controller and visible for another. Well this is very easy to achieve - just use setNavigationBarHidden:animated: in viewWillAppear: for each view controller
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES/NO animated:animated];
}
I am pushing a viewController onto the UINavigationController with animation, and the controller being pushed on is basically doing something like:
--- app delegate:
[((UINavigationController *)window.rootViewController) pushViewController:initialController animated:YES];
--- initial controller:
- (void)viewDidLoad {
[super viewDidLoad];
if (self.shouldSkipThisController) {
SomeOtherViewController *someOther = [[SomeOtherViewController alloc] init];
[self.navigationController pushViewController:someOther animated:NO];
}
}
This is causing some CRAZY behavior which I don't understand at all. Basically, it seems like the navigation items set on SomeOtherViewController are being covered up by some strange other button that has the name of the title in a back button. It looks like although SomeOtherViewController is setting it's own left and right navigation items, they are covered up by the "default" back button--- and then if I tap on that back button, then just the navigation bar at the top animates-- and THEN SomeOtherViewController's navigation items are then there.
The only thing I could find that sort of worked was to either 1) not animate the push of the initial view controller in the app delegate, or 2) move the shouldSkipThisController condition into viewDidAppear: method.
However, neither of those options are ideal... Any help could be greatly appreciated.
I am using UINavigationController to direct some view controllers.In some view controller, I don't want to use UINavigationBar, but in some others i may use. Now I am try to pop one view controller using UINavigationBar to its previous one which hide UINavigationBar. But when poped, there is one wired black space under screen. After you rotate the screen, the space will disappear.
the normal view controller A should be like this:
when press the text button, a view controller B will be pushed, which is as followings:
when click back button on the navigation bar. A will come out.but there is a black space at the bottom.
If rotate the screen, the space will disappear. And also in A's - (void)viewWillAppear:(BOOL)animated method i hide the navigationbar and let the screen autorotate.
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
[self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0];
}
whats wrong with this situation? Any help will be appreciated.
I add setNavigationBarHidden: method in the back button action method. it works. If i add this method in viewWillDisappear: method or others, it seems it doesn't work. The navigation bar will have effect on next appear view controller. which means, there will be a black space in the next view controller in the navigation stack.
Finally, i add a action method for the back button and setNavigationBarHidden:YES in the method, which is as follows:
- (void)backBtnClicked:(id)sender
{
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController setNavigationBarHidden:YES];
}
I got a tabbar application.
There is only 2 tabs in the tabbar. First tab is a NavigationController, there are two views in the NavigationController - root and detail views, second is a TableViewController. Second works perfect, but the the first doesn't.
I start in first view (NavigationController). Then go in this NavigationView to the detail view. Then, for example, i go to the second tabbar view. Then go back to the first, but i dont see the root view, but the detail view.
How can i open the root view every time?
Use the UITabBarController delegate method tabBarController:didSelectViewController: like this:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
if (viewController != tabBarItemForNavControllerTab) {
[self.navControllerInFirstTab popToRootViewControllerAnimated:NO];
}
}
Also make sure that delegate is setup properly, when creating your UITabBarController and you change the code from my snippet to fit your controller names.