mercredi 6 juillet 2016

iOS: Why does hidden button still receive tap events?

According to the Apple docs, hidden UIButtons should not receive tap events.

However, our app has a UIButton receiving tap events despite being hidden.

This function is the IB Action invoked when the button is tapped. When the button is removed from Storyboard, this function doesn't get invoked. When the button is added to Storyboard, the function gets invoked -- even though the button is hidden.

To verify that the button is hidden, we put a breakpoint inside the function and ran expr sender.hidden from the Xcode debugger. The result: true.

The stack trace shows the IB Action is triggered by code in UIApplicationMain, not our code.

Through the Connections Inspector, we confirmed there is no other trigger for the IB Action except the mysterious button.

Thoroughly confused. Suggestions?

@IBAction func buttonTapped(sender: UIButton) {        
    // If here, handle tap
    ...
}

Aucun commentaire:

Enregistrer un commentaire