2

I have seen lots of code to hide the whole tabbar. I am using tab bar controller in storyboard. Example of my tabbar

If I had third and fourth buttons how could I hide just the second but still have 1, 3 and 4 buttons shown?

Kampai
  • 22,848
  • 21
  • 95
  • 95
MwcsMac
  • 6,810
  • 5
  • 32
  • 52

2 Answers2

1

Well just hide the button itself.

button2.hidden = true

You will need to create an outlet.

@IBOutlet var button2 : UIButton!

And link it to the button in Interface Builder

AMAN77
  • 6,218
  • 9
  • 45
  • 60
  • Pretty sure thats not possible. – sbarow Nov 20 '14 at 07:09
  • Ok I have tried the suggestion above but it dose not work. Let me rephrase the question as can I hide a relationship segue? And be selective on which ones to hide. – MwcsMac Nov 22 '14 at 19:17
  • Also I do know that if I goto the view controller that I want to hide. And disable the bar item that it can not be selected. So can I add to that and hide it all together? – MwcsMac Nov 22 '14 at 19:25
0

Ok to hide the button the following can be done. I used this code in a table view to add the editing function and change the title of the button based on the the click. But I modified it for this post just to show that when I clicked on the button again it would make it disappear.

var condition: Bool = true
@IBAction func buttonEdit(sender: UIBarButtonItem) {
    if(condition == true) {
        tableView.editing = true
        sender.title = "Done"
        condition = false
    } else {
        tableView.editing = false
        sender.title = "" // This clears the title
        sender.enabled = false // This disables the button
        sender.image = UIImage() // This would clear the image
        condition = true
    }

}
MwcsMac
  • 6,810
  • 5
  • 32
  • 52