How to go back to UiTabBar home page from UiTableViewController that is loaded upon button click from a button within the homepage tab? - ios

i have created a universal tabbed iOS application in Swift 2.0, the application has 3 tabs in the first tab, in the viewcontroller in storyboard i have placed a button upon which when pressed a UiTableView is loaded and it has a feature to add cell (a note taking feature embedded within the app), my issue is that once the UITableViewController is loaded i cannot go back to the previous page, its like this:
I have a TabBarController linked to a NavigationController which is linked to a HomepageViewController and When button is clicked, NavigationController linked to UITableView which shows ItemDetailViewController
My problem is that once i get to the UITableViewController i cannot go back to the home tab - HomeViewController
I have tried adding a UiBarButton to the top left of the UITableController and using poptorootviewcontroller , but it didnt work, any help will be appreciated.

According to my understanding, your tabbar controller is at the root of window. You can access it as self.window.rootviewcontroller. After that, you can use tabar.selectedIndex to switch tabs.

Related

How can I make UITabBarController respond to a single click for a tab?

I am trying to use UITabBarController in swift 4.2: https://developer.apple.com/documentation/uikit/uitabbarcontroller to navigate between 2 views, lets say ViewController1 and ViewController2 , each of these controllers being embedded in his own navigation controller. I am using swift 4.2 and deployment target is IOS 12.1. (Image with storyboard and controllers)
But it seems the default behavior is that to go to another tab you need 2 clicks(taps) as described also in Why i need to tap tabBarViewController item Twice to navigate to different View Controller - iOS
At first I thought it is something that I am doing wrong, but also trying the template provided by the IOS team for the tab bar it seems that the workflow is the same.
I created the UITabBarController from the storyboard. I also tried creating a custom tab bar class but did not manage to make it work. If I click once on ViewController2's tab, the viewDidLoad() and viewDidAppear() for ViewController2 are being called but the UI is not refreshed. After clicking anywhere in View or try to scroll the View is refreshed with the correct ViewController2.
Can you help me with this issue please? How can I make UITabBarController respond to a single click for a tab?

Swift NavigationControllerBar Back Button

I am new in iOS development and in Swift. I have a question. I added in one of the ViewController NavigationController. But I have some problems with back button cause it doesn't appear on other Views. I tried with self.pushViewController() and with self.present() but it doesn't work. If I mark in NavigationController Is Initial View Controller then everything is fine but I don't want it because then app starts with this screen(where I have NavigationController).
Please help me, what I should to add or to write?
This is an image of my storyboard
And this is what I have if I run and go to another ViewController, as you can see I don't have navigation bar and back button.
You got 2 options :
1) Add a navigation controller in the root ViewController, Hide throughout except the last one. Make sure you push the last VC so Back option will be there by default
self.navigationController.pushToViewController(BarCodeViewController)
2) Use a custom View on top of last viewController add a custom button to that view. But this time present it from previous ViewController
self.present(BarCodeViewController)
when back button clicked dismiss it by adding target to the button. self.dismiss()

Tab bar/tab item disappears on two of tabs in my app

In my storyboard app, I have a UITabController, which leads to a number of UIViewController.
Two of these primary UIViewController have a series of buttons which lead to secondary UIViewController.
Each of those secondary UIViewController displays html content, and they each have a button to go back to the primary UIViewController and a button to go back to the UITabController.
On the primary UIViewController, the tab bar displays fine with the various items. If I click a button to go to a secondary UIViewController, and then click the button to take me back to the primary UIViewController, I noticed that the UITabBar and items are not appearing.
Is there a setting that I need to change with regards to the tab bar to force it to display on the primary view when returning from the secondary view?
(PS ignore the website that shows in the screenshot of the secondary view, for some reason in the simulator it shows the website, but when I compile and run on an actual device it displays the correct html file that is hosted on the same site).
When you are using modal segue then it is meaning present UIViewController.
Unlike push(show) navigation, present UIViewController can be said overlay it's UIViewController on top of it.
Let's say viewController1 is one of tabViewController item and you are going to present viewcontroller2.
Then you are present viewcontroller1 again on top of viewController2.
This is meaning at the bottom there's viewController1 nested in UITabController and viewController2 on top of it and another viewController1 on top of it again.
That's UIViewController doesn't have tab items and tab bar.
So to go back, you'd rather to use dismiss UIViewController instead of present it again.

How to load the second tab in a UITabBarcontroller on a button click..??

I have a initial UIViewController. I have two buttons on the UIViewController, one being Tutorial and the other being Start.
When I click on Tutorial then I will be navigating to a UITabBarController where Tutorial is the default(first) tab. I have no problem with this. I have done by holding and right clicking and dragging to UITabBarController and selecting modal.
But when I click the Start button I will have to navigate to the second tab on the UITabBarController. How can this be done???
Just set the UITabBarController.selectedIndex property to the index of the tab you want to use.

How to go from a single view to a tab bar view

need some help here
My problem is, my app starts with a single view, it shows a menu made with buttons that takes me to different places, one of this places is another kind of menu, but this menu is a tab bar menu, so the thing is, I made a new file with its .xib, I added the tab bar controller, and i Linked all the sections of my tabs with its viewcontrollers...
this means that I have my first menu ready, I have my view controllers ready, I have my menu on the tab bar ready....
so my problem is...
how can I go from my single view (the first view that I see and that doesnt include a tab bar), to the new screen with tab bar controller in it after pressing a button???
help me please
Note: I'm using XCode 4.2 and I'm not working with storyboards (requirements of the app)
You have three options to show your viewController content :
1.using presentModalViewController:
2.add the viewController view as a subView to the current viewController. in your case : [singleViewController.view addSubView:tabBarViewController.view];
3.or if your simple ViewController is the navigation root viewController you can push other viewControllers to its navigation stack. (as #roronoa zorro described).
You might have added all the next viewControllers on the taBarController so if you have want to tabbar on to next screen you simplr have to push the tabbarcontroller on the navigationcontroller.
[self.navigationController pushViewController:TabBarControllerObj];

Resources