0

So, I'm making an app that after having the user select their level of education from a picker view and if they select college education a number of buttons are supposed to appear saying 'associates degree' 'bachelor's degree' and 'master's degree'. I know I need to make an if statement like this:

func pickerView(pickerView: UIPickerView, row: Int, forComponent component: Int) -> String! {
   if educationLabel.text == educationLevel {
     return education[row]
     If row = "College Graduate"
     //Hidden buttons code
     Else
     //Hidden buttons
}

but I'm unsure of how to write the code that keeps all three buttons hidden as every example I've come across only had one button. I'm assuming it would be similar to what is suggested here: how to hide/show a button in swift with buttons two and three added on but I am using Swift 4 and am unsure how much of the answer I can use since it uses Swift 3. Can someone please help me out?

Kamran
  • 14,987
  • 4
  • 33
  • 51
yukimoda
  • 181
  • 10

1 Answers1

0

To hide or show buttons, you use isHidden property. To hide buttons:

button1.isHidden = true
button2.isHidden = true

To show buttons

button1.isHidden = false
button2.isHidden = false

Also the code after return doesn't get executed, you know that right?

DionizB
  • 1,487
  • 2
  • 10
  • 20
  • Oh yes I realize that now, sorry. It was very late when I posted the question and I couldn't think of how else to connect the two ideas other than to attach the hidden buttons to one of the pickervie functions. – yukimoda Apr 19 '18 at 14:03