when using text field
alert.showEdit("title", subTitle: "This alert view shows a text box")
if text field is empty i don't want to close dialog and show user a message that 'please enter text',
how to prevent from close when dialog button is clicked?
i have modified source code just commit sideview() in buttonTapped(_) method, and manually close dialog by calling hideview or close function
func buttonTapped(_ btn:SCLButton) {
if btn.actionType == SCLActionType.closure {
btn.action()
} else if btn.actionType == SCLActionType.selector {
let ctrl = UIControl()
ctrl.sendAction(btn.selector, to:btn.target, for:nil)
} else {
print("Unknow action type for button")
}
if(self.view.alpha != 0.0 && appearance.shouldAutoDismiss)
{
// hideView()
}
}
Hi, I faced the same problem and I resolved it differently.
You can just set "shouldAutoDismiss" in appearance and then, manually dismiss the alert.
Maybe it will not be helpful for you, but it can be for others ;)
let appearance = SCLAlertView.SCLAppearance(
shouldAutoDismiss: false
)
let alert = SCLAlertView(appearance: appearance)
alert.addButton("Keep open") {
// Your code here
}
alert.addButton("Close") {
alert.hideView()
}
alert.showEdit("Title", subTitle: "subTitle")
@YoannLth yes, this helped me! Thanks for sharing 馃槉
What is the Objective C 'equivalent' - that performs this? I don't see AutoDismiss - thx!
let appearance = SCLAlertView.SCLAppearance(
shouldAutoDismiss: false
)
let alert = SCLAlertView(appearance: appearance)
alert.addButton("Keep open") {
// Your code here
}
alert.addButton("Close") {
alert.hideView()
}
alert.showEdit("Title", subTitle: "subTitle")
Most helpful comment
Hi, I faced the same problem and I resolved it differently.
You can just set "shouldAutoDismiss" in appearance and then, manually dismiss the alert.
Maybe it will not be helpful for you, but it can be for others ;)
let appearance = SCLAlertView.SCLAppearance( shouldAutoDismiss: false ) let alert = SCLAlertView(appearance: appearance) alert.addButton("Keep open") { // Your code here } alert.addButton("Close") { alert.hideView() } alert.showEdit("Title", subTitle: "subTitle")