I've experienced strange bug in Latest Xcode 11.0 My code:
let button = ASAuthorizationAppleIDButton(type: .default, style: .black)
button.translatesAutoresizingMaskIntoConstraints = false
button.cornerRadius = 10
button.addTarget(self, action: #selector(appleSignInButtonSelected(_:)), for: .touchUpInside)
Selector never called, but if I change event to touchDown, everything works.
I think it is apple bug. Use touchDown instead of touchUpInside.
I've experienced same issue. In my case I've had UITapGestureRecognizer
attached to main view of the view controller. Setting property cancelsTouchesInView
of the gesture recognizer to false helped.
I found out the best way to do this is to just use UITapGestureRecognizer
let button = ASAuthorizationAppleIDButton()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleAuthorizationAppleIDButtonPress))
button.addGestureRecognizer(tapGesture)
Using addTarget(_:action:for:) with .touchDown would require the user to long tap the button (~1s longer than normal) before action is detected which is unusual.
Apple even rejected my app submission because "tapping the Sign in with Apple button did not produce any actions".
I recommend just using a tap gesture recognizer to avoid any issues.
I found that the ASAuthorizationAppleIDButton
did not receive any tap gestures at all (down
or upInside
) if there was a layout problem with its parent.
In my case, I had left out a constraint in one of the parent views, which caused the ASAuthorizationAppleIDButton
to be outside the frame of the parent view.
This was in a storyboard, so there was a red arrow and warning about it, but I had missed that initially. I found this by debugging the view hierarchy and noting the position of each of the ancestor views up the tree.
The fix is to ensure that there are constraints to keep the ASAuthorizationAppleIDButton
within the frame of its ancestors.
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