segue to the TabbarController - ios

In my image, my first Tabbar is HomeViewController and the second Tabbar is CameraViewController.
What is the proper way to segue to the Tabbarcontroller? You can see the read line, I try to segue this but I
always get the back button in my HomeViewController and It display weird like not showing the navigation name.
In CameraViewController I hide the Tabbar for the use camera button. I try to use segue programmatically like this one.
[self performSegueWithIdentifier:#"sample" sender:sender]
but It doesn't work properly. Is this possible to segue to TabbarController?

You can't call
[self performSegueWithIdentifier:#"sample" sender:sender]
Because you're in TabBarController already. You could implement custom flow. By pressing "Back" button - just show TabBar and change selected tabBarItem for example…
update
used this
[self.tabBarController setSelectedIndex:0];

Related

Navigation bar disappear after create viewcontroller dynamically

I'm new to iOS and trying to build one AR app with navigation bar, I defined 3 viewcontroller in the app, and using storyboard and navigation bar to switch the viewcontrollers:
VC1 - Home view, there is one button navigated to VC2;
VC2 - this view controller will call camera to scan image marker; when the image was identified, I just instantiate VC3 programmatically.
VC3 - just showing some information for the image, I added 2 buttons here which will navigated to VC1 and VC2 seperately.
So VC1->VC2, VC2->VC1 are OK as the navigation bar configuration, the problem is when I click button in VC3 to VC1 or VC2, both navigation bar in VC1 and VC2 disappear. It seems I missed some configuration here, can anyone tell me how to make the navitation bar always there?
You can check navigationBar's visibility in method viewDidAppear of VC1 and VC2 like this:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(#"navigationBar is hidden:%#\n",
self.navigationController.navigationBar.hidden ? #"YES": #"NO");
}
It should be YES in VC1 and VC2, you probably change navigationBar's visibility in somewhere, find it then fix it.
I have solved my problem from below link, it is working perfectly
Change destination of Navigation Back button

UITabBar disappears when NavigationController pop the view back to the said ViewController

I have a UITabBar on a UIViewController, attached from the Interface Builder, which is working fine, until I have a button that pushes another ViewController to the screen (ex: Login screen) via NavigationController.
After the other ViewController is popped, the screen returned to the original ViewController, but the TabBar is disappeared. How can I fix this? Thanks.
-(void)viewWillAppear:(BOOL)animated{
[self.tabBarController.tabBar setHidden:NO];
}
use This in popped controller

popViewController not working with storyboards

I create a UINavigationController (as a initial screen) and connect them with my UITableViewController (as a root).
Next, I create another UINavigationController and connect with my UIViewController. Inside my UITableViewController I connect my first cell with UINavigationController (That was connected with my UIViewController) (Segue -> show).
When I run the project my table appears, when I select my first row, my UIViewController appears. Thats great!
When I was in my UIViewController the back bar button doesn't appears, in my case I create a left bar button, that will run a function to dismiss that view and go back to my UITableViewController, for that I use many codes:
-(void)back{
NSLog(#"Called");
[self.parentViewController.navigationController popViewControllerAnimated:YES];
}
-(void)back{
NSLog(#"Called");
[self.navigationController popViewControllerAnimated:YES];
}
-(void)back{
NSLog(#"Called");
[self.navigationController popViewControllerAnimated:YES];
}
But all of they doesn't works and my view don't dismiss, how can I solve this problem?
The problem is that your navigation controller, that you call from your table view cell, has only a single view controller (yours) on its navigation stack. So it cannot pop anything from this stack, else the stack were empty.
What you have to do instead is to dismiss the navigation controller itself.
I think that the solution would be to remove the second navigation controller. Since the TableView is already embedded inside a Navigation Controller, the show segue to the UIViewController must be directly connected to it.

Show tab bar on modal View

On click button "Go!" show white View Controller.
I want show tabbar on white ViewController, but it doesn't show. How i make this correctly? Swift please, thanks.
Do this in firstView,so the firstViewController embed in NavigationController,then make a push segue,the tabBar will not dismiss.
You have to use navigation controller to see tab bar. by presenting modally you can't get tab bar in white controller.
Swift code:
let secondViewController = self.storyboard.instantiateViewControllerWithIdentifier("SecondViewController") as SecondViewController
self.navigationController.pushViewController(secondViewController, animated: true)
I think you are using wrong segue just delete old segue and add new segue this way by pressing control key:

How to Force Back Button to Go to First View Controller (swift)

I have storyboard of several view controllers embedded in Navigation Controller.
Due to navigation logic in later views of storyboard, the back button (in the left upper corner, in navigation bar) does not go back to the first view. I am wondering where and how to change this behaviour of Back button of second view only. Appreciate any ideas, examples.
Of course you could implement a custom back button. But there is also a nice way to keep using the default button.
Simply check if the current viewController is still in the navigation stack in viewWillDisappear before you call super.viewWillDisappear(). If it is not, the back button has been pressed. Then you can do the popToRootViewControllerAnimated.
override func viewWillDisappear(animated: Bool) {
if (navigationController?.viewControllers)!.contains(self) {
// back button was pressed
self.navigationController?.popToRootViewControllerAnimated(animated)
}
super.viewWillDisappear(animated)
}
The custom back button appears to be the best solution. The code inside your action method would look like the following in swift:
self.navigationController?.popToRootViewControllerAnimated(true)
//Just change the true to false if you don't want it animated.
I hope this helps (if you had not already found the answer). Cheers!
If you meant to say: Prevent Back Button Navigating to Previous Controller and move to first view controller:
You could do this by creating a custom back button - drag a button in storyboard to the top left of the navigation bar, and wire it up to your view controller. In your custom back button's selector write:
[self.navigationController popToRootViewControllerAnimated:YES]
Assuming you have a view controllers stack like : VC1 > VC2 > VC3, and you want to back to VC1 when tapping back on VC3, then you could set this code in VC2 :
[self.navigationItem setBackBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:#"Back" style:(UIBarButtonItemStylePlain) target:self action:#selector(backToVC1)]];
Then, always in VC2 :
- (void)backToVC1
{
[self.navigationController popToRootViewControllerAnimated:YES];
}

Resources