Last active
March 31, 2024 18:00
-
-
Save TheCodedSelf/c4f3984dd9fcc015b3ab2f9f60f8ad51 to your computer and use it in GitHub Desktop.
Disable Alert Controller button if Alert Controller text field is empty or whitespace
This happens when you have a function with wrong argument names.
Change the argument name from: .UITextFieldTextDidChange
To: UITextField.textDidChangeNotification
I changed, but anyway I get Type of expression is ambiguous without more context"
I get error: Cannot infer contextual base in reference to member 'UITextField'
thank you.
really cool, thanks.
I would add
okAction.isEnabled = false
before add it toalertController
since the TextField appears empty the first time.
I second this. The OK button will start out as enabled if this is not done. Minor line of code but pretty essential given the purpose of the whole procedure.
Pretty neat. I didn't want to create a new method in an already clustered viewcontroller.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created service-class for such kind of alert presentation + added text field delegate to restrict non-digit user input:
https://gist.github.com/SergLam/652db7cec81e7e5a5c0fda070d300a12