Comments (3)
I'm sorry but at the moment it's not possible, because when you tap a button automatically it dismisses the alert.
About the text, yes, you can edit how text field works.
from pmalertcontroller.
A solution to this that doesn't rely on the library can be found here:
https://nshipster.com/uialertcontroller/
from pmalertcontroller.
Though I'd post this here incase it helps anyway else out trying to do this and I've just switched our alerts to PMAController. I'm pretty new to swift so might be better ways to do it :)
Add the textfield as a subview of the content stack view (so I can have horizontal buttons), with an editing changed UIControl event
let textField = TextField(frame: CGRect(x: 0, y: 0, width: 230, height: 40))
textField.placeholder = "Enter your email address"
textField.backgroundColor = ColorCompatibility.lightBackground
textField.layer.cornerRadius = 8
textField.font = UIFont.systemFont(ofSize: 15)
textField.keyboardType = UIKeyboardType.emailAddress
textField.autocapitalizationType = .none
textField.accessibilityIdentifier = "forgotPasswordInput"
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(field:)), for: UIControl.Event.editingChanged)
alert.alertContentStackView.addArrangedSubview(textField)
I'm only using a tag here as an example, but add your button action as you normally would and set i to disabled.
let submitAction = PMAlertAction(title: "Submit", style: .default, action: {() in }
submitAction.tag = 0xAC
submitAction.isEnabled = false
Now you can listen for changes on the textfield and decide what to do...
@objc func alertTextFieldDidChange(field: UITextField){
let alertController: PMAlertController = self.presentedViewController as! PMAlertController
if let submitAction = alertController.view.viewWithTag(0xAC) as? UIButton {
submitAction.isEnabled = (field.text?.isEmail)
}
}
from pmalertcontroller.
Related Issues (20)
- Lots of Xcode 10 errors HOT 2
- Change Button Colour When Selected HOT 3
- Send notification on alert dismiss
- Not presenting nested Alerts HOT 1
- How to show buttons horizontally? HOT 5
- Invalid Task Error after Pod Install HOT 9
- Turning off auto dismiss when tapping button HOT 2
- Can I keep the alert portrait even though the view is in landscape? HOT 2
- xcode10.2 build error HOT 2
- Can I override the viewDidDisappear method in PMAlertController HOT 1
- PMAlertController textfield access via objc HOT 4
- Build error when not using dynamic framework in podfile
- Black background when using Tabbar HOT 4
- Swift Compiler Error in Swift 5 HOT 2
- Display two alertVC
- Can't Set Attributed String
- How to customize like fonts?
- App Store Connect operation error HOT 2
- Missing SPM Support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pmalertcontroller.