Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent from close when button is tapped #277

Closed
samigehi opened this issue Dec 16, 2016 · 4 comments
Closed

Prevent from close when button is tapped #277

samigehi opened this issue Dec 16, 2016 · 4 comments

Comments

@samigehi
Copy link

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?

@samigehi
Copy link
Author

samigehi commented Dec 16, 2016

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()
        }

    }

@YoannLth
Copy link

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")

@anushkmittal
Copy link

@YoannLth yes, this helped me! Thanks for sharing 😊

@JonElster
Copy link

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants