Tabbar dissapears when removing item in UITabBarController - ios

I have defined an scene with a tab bar controller in my main storyboard.
I want to programmatically remove one tab.
If I execute this code in the UITabBarController class viewDidLoad method
self.viewControllers!.remove(at: 1)
the tabbar is removed completely from the screen.
Why could be causing this?

I fixed it. Problem was that I was trying to remove a tab in the viewDidLoad method. I placed the code in the viewWillAppear and it worked fine.

Related

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()

xcode: can't see in storyboard a navigation item

I have added to my tableView with navigationController a bar button with text "Start!".
But I can not see it anymore in the storyboard.
In my build I can see it:
I think this is also the reason for this error log message:
pushViewController:animated: called on while an existing transition or presentation is occurring; the navigation stack will not be updated.
What can I do to make the bar button visible again?
The tableviewcontroller is covering the navbar in your storyboard. Check the properties in the storyboard and verify that your tableviewcontroller is inheriting his geometry. (setting is called inferred)

Destination Controller Showing without Navigation Bar

This is driving me crazy! I am creating a segue from one of the UITableViewCells to another UITableViewController. A Navigation controller sits between them as shown in the screenshot below:
When I reach the Samples UITableViewController it appears without the NavigationBar as shown below:
Am I doing something wrong?
Your first UITableViewController is in a navigation controller too right ?
If not, it's normal, see this post.
If your first UITableViewController is in a navigation controller, I had the same problem, if you use the push segue (deprecated) it should resolve your problem.

iOS Custom TabBar and Storyboards

I am following a post here showing how to add a custom center tab bar item.
What's the best way of adding a custom centre button to a tab bar?
My only question is where should the code be put? I am using storyboards and right now I have it placed in viewwillappear for my default view that is shown. Should this go in a more generic or global area?
Create a subclass of the UITabBarController, say MyTabBarController.
In the storyboard, drag the standard UITabBarController into the scene, and change its class type to MyTabBarController.
In the MyTabBarController, insert the code within its viewDidLoad method.
If you put it within the viewwillappear method, it will be added multiple times since the viewwillappear will be called every time the tabbarcontroller is displayed.

Adding toolbar to a ViewController in storyboard

I'm using storyboard to create an iPad app. On the main view I have a toolbar and a bar button item, let's call it "show". Then I have dragged a table view controller into the storyboard. I have also added a subclass of UITableViewController to the files and made the class of the dragged table view controller to be that subclass. And I made a popover segue from the "show" button to the table view controller. It works fine, meaning that when "show" pressed I see the popover showing the correct data that I set in the table view. What I cannot seem to figure out is how to put a toolbar on top of the table view in the popover. I took a step back and used a UIViewController instead of UITableViewController and still cannot add a toolbar by dragging it to the view. Any help will be appreciated.
I ended up putting the TableViewController within a NavigationController and the latter in a PopoverController, all in the code, without using IB. I found this an easier solution to get the toolbar than anything else that might work.

Resources