How can I simulate a button press within a View in using Swift. I'm trying to get Calendar permissions and have a function setup to check this authorization when I click the start button this currently runs
@IBAction func start(sender: AnyObject) {
//loads prompt to "Allow" or "Don't Allow" calendar permissions
eventStore.requestAccessToEntityType(EKEntityTypeEvent, completion: handler)
//checkAuth function looks at calendar authorization to get current status
and then acts accordingly to dismiss View or load Privacy Settings
checkAuth()
}
I need to be able to simulate a button press of the Start button to trigger the start() func once again. The only thing I've found so far seems to be in Objective-C
[buttonObj sendActionsForControlEvents: UIControlEventTouchUpInside];
I'm not familiar with Obj-C and need a way to implement this in Swift if possible...Thanks
The Swift translation of:
[buttonObj sendActionsForControlEvents: UIControlEventTouchUpInside];
is:
button.sendActions(for: .touchUpInside)
and it should in fact simulate a button push.
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