Using a UIButton to enable or disable other UIButtons

I am new to xcode and swift. I am running xcode 10 and swift 4.2.


I need for a UIButton to enable other buttons and I and running in circles

I want to use the generate button to enable the buttons below it. I have tried using buttonName.isEnabled = false but I get an error. Any assistance would be grteatly appreciated. Thanks in advance

Answered by Claude31 in 338226022

All this is not very clear. You should clarify and show the complete code of the viewController if you want some help.


When you tap the button, you call generateButton (a strange name, it does not generate anything) and want to change a button (enable / disable). Is it this ?


What are those buttons below generate ?


Is the button editButtonItem or something elese ?

What is fetch function ?

What is buttonPressed ?


If my understanding is correct, you should:


@IBAction func generateButton(_ sender: UIButton)
    {
        editButtonItem.isEnabled = !editButtonItem.isEnabled     // Toggle between enabled and disabled
        if (buttonPressed == false) { errorMsg() }
        else { fetch() }
    }

Sorry was supposed to have a .png file for visuals

EJAMM wrote:


I am new to xcode and swift. I am running xcode 10 and swift 4.2.


I need for a UIButton to enable other buttons and I and running in circles


I want to use the generate button to enable the buttons below it. I have tried using buttonName.isEnabled = false but I get an error. Any assistance would be grteatly appreciated. Thanks in advance

@IBAction func generateButton(_ sender: UIButton)

{

editButtonItem.isEnabled = false

if (buttonPressed == false) { errorMsg() }

else { fetch() }

}

@IBAction func highLow(_ sender: UIButton)

{

errorMsg()

getNumber = sender.tag

}

@IBAction func highHigh(_ sender: UIButton)

{

errorMsg()

getNumber = sender.tag

}

@IBAction func lowLow(_ sender: UIButton)

{

errorMsg()

getNumber = sender.tag

}

@IBAction func lowHigh(_ sender: UIButton)

{

errorMsg()

getNumber = sender.tag

}

@IBAction func random(_ sender: UIButton)

{

errorMsg()

getNumber = sender.tag

}

Accepted Answer

All this is not very clear. You should clarify and show the complete code of the viewController if you want some help.


When you tap the button, you call generateButton (a strange name, it does not generate anything) and want to change a button (enable / disable). Is it this ?


What are those buttons below generate ?


Is the button editButtonItem or something elese ?

What is fetch function ?

What is buttonPressed ?


If my understanding is correct, you should:


@IBAction func generateButton(_ sender: UIButton)
    {
        editButtonItem.isEnabled = !editButtonItem.isEnabled     // Toggle between enabled and disabled
        if (buttonPressed == false) { errorMsg() }
        else { fetch() }
    }
Using a UIButton to enable or disable other UIButtons
 
 
Q