Basically, I have a UINavController a RootView controller (plain ViewController), then a TabBar Controller.
When I call self.title, it changes the tab items title, not the navcontrollers title.
Nav Controller
ViewController
Tab Bar Controller
View A
View B
View A is where I call self.navigationController?.title and self.title, nothing works.
The reason you can't set the title with self.title, is because the navigationItem, in your setup apparently belongs to the tab bar controller, not controller A. You can set the title with self.tabBarController.title.
Related
Tab bar have three view controllers. and I want to start third view controller of navigation controller when opening the tab bar. When tapping back button on third view controller, move to second view controller.
How to start third view controllers and push first, second view controllers.
It has each segue.
just access your navigation controler and call setViewControllers
let nvc = (tabBarController?.viewControllers?[0] as? UINavigationController)
nvc?.setViewControllers([UIViewController1, UIViewController2, UIViewController3], animated: false)
I have a view controller that has a navigation bar. It is the root view controller of the navigation controller. I have another view controller that can be segued from a button on the first controller. Up to this point, everything works fine; there are navigation bars on both view controllers.
However, from the second view controller, I want to be able to segue back to the first controller. When doing this, it removes the navigation bar from both of the view controllers.
How can I get the navigation bar on both view controllers with buttons as transitions? Thanks!
Implement below method in your both viewcontroller,
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
You may hiding navigationbar somewhere.
Try this in storyboard:
Select the navigation controller -> Attributes Inspector -> Under Navigation controller and Bar Visibility leave the "Show navigation bar" blank
PREAMBLE
VIEW CONTROLLER A: Has no navigation bar.
VIEW CONTROLLER B: Has a navigation bar.
At present: when segueing from VIEW CONTROLLER A to VIEW CONTROLLER B:
The navigation bar just appears [ rather than transitioning in sync with the VIEW CONTROLLER B body ].
QUESTION
How do I force the navigation bar to segue in sync with the view controller body ?
1.In view will appear of ViewController A hide navigation bar and viewwilldisappear in ViewController B show navigation bar.and
2.hide navigation bar in ViewControllerA and show navigation bar in ViewController B viewwill appear
3.when you push view controller use animated in the parametes [self.navigationcontroller pushviewcontroller:viewb animated:YES];
I have a base nav controller which has a tab bar controller nested inside. inside that tab bar controller is another nav controller nested in it. If I'm in the child nav controller I can pop to root view in one of the views but it only takes me to the root view of the CHILD nav controller. Is there a way to pop back to the first nav controller?
If you are using storyboard then you can use Unwind segue approach which always works for me
Just Control + drag from "Pop to Main Screen" UIButton to Exit (green button at bottom of scene) select unwind method declared in first screen with title "Main" e.g.
-(IBAction)customUnwind:(UIStoryboardSegue *)sender
{
NSLog(#"Unwind successful");
}
Try this,
You can pop to root view from the child nav controller by
UITabBarController *tc = (UITabBarController *)self.navigationController.parentViewController;
[tc.navigationController popToRootViewControllerAnimated:YES];
How do you access an element in a tab bar controller and change its value? For instance i want to access a particular view controller in a tab bar controller and change a property in the view controller. Been stuck with this for a while. I have called tab bar init with nib name and initliased the tab bar. Now i need to know how to access one view in it. I tried
UITabBarController *newTabBar = [[UITabBarController alloc]initWithNibName:#"PlaceTabBarControllers" bundle:nil];
[newTabBar.selectedViewController setView:listViewController.view];
but this doesnt work.
UIViewController *viewController = [newTabBar.viewControllers objectAtIndex:0];