I need to disable a button if the key does not exist in the dictionary. I have used the setEnabled functionality of the UIButton but the image that has been set default still appears.
The code looks like this:
if([self.InfoDictionary objectForKey:ButtonExist])
{
[button1 setEnabled:YES];
}
else
{
[button1 setEnabled:NO];
}
The image still appears when I run in the simulator. Need some guidance on this.
The disabled attribute is a boolean attribute. When present, it specifies that the button should be disabled. A disabled button is unusable and un-clickable. The disabled attribute can be set to keep a user from clicking on the button until some other condition has been met (like selecting a checkbox, etc.).
There's another way you can disable the submit button after the first click. You can simply remove the onclick event handler by setting its value as null.
As you can see, the button is disabled just by adding disabled(agreedToTerms == false) to the list of modifiers. Like many other SwiftUI modifiers, you can lift disabled() so that it's run on the section or even the whole form depending on what behavior you want – just move it to come after the section, for example.
Here use setTimeout, to enable it after 30 seconds. In the anonymus function of setTimeout. Modify the DOM property is also called disabled and is a boolean that takes true or false. Save this answer.
enable = YES
property of button performs the action when clicked.
enable = NO
property prevents action to be executed on click.
If you want to hide the button then you can set the hidden
property as YES
or vice versa. Other way to hide is by setting the alpha
property to 0
(invisible) or 1
(visible)
Also you can set userInteractionEnabled
property of UIButton
if([self.InfoDictionary objectForKey:ButtonExist])
{
[button1 setEnabled:YES];
button1.userInteractionEnabled = YES;
}
else
{
[button1 setEnabled:NO];
button1.userInteractionEnabled = NO;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With