material-components-ios
material-components-ios copied to clipboard
[Cards] Adding touchUpInside event to MDCCard in the storyboard does nothing when the card is touched
Adding a touchUpInside event to a MDCCardView in the storyboard is not working
Reproduction steps
Steps to reproduce the behavior:
- Add an UIView of custom class MDCCard in a storyboard
- Add @IBAction func cardViewTouched(_ sender: Any) { print ("touched") } in a viewcontroller 3 Link the IBAction through storyboard with the touchUpInside event of the MDCCard
Expected behavior
When I tap the card, "touched" should be printed in the console
Actual behavior
When I tap the card, nothing is be printed in the console
Platform (please complete the following information)
- Device: iPhone6 simulator
- OS: 12.1
Internal data
- Associated internal bug: b/124917659
The title doesn't have a [Component] prefix.
Thank you @bjimenezned .
We'll attempt to repro and add to Dragons.
Sounds similar to https://github.com/material-components/material-components-ios/issues/5513
Same result even after setting 'isUserInteractionEnabled = true ' or ' interactable = ON' on MDCCard . It still does not respond to click events
Works fine for me: (Updated code)
//View Header @IBOutlet weak var viewHeader: MDCCard!
func setUpView() {
viewHeaderMDCCard.enableRippleBehavior = true
viewHeaderMDCCard.isInteractable = true
viewHeaderMDCCard.addTarget(self, action: #selector(tap(_:)), for: .touchUpInside)
}
@objc func tap(_ card: MDCCard) {
print("card tapped")
}
@mehulparmar4ever , doesn't for me.
I am using it in UITableView & Inside UITableviewCell,I have drag & drop UIView & Set Class "MDCCard" & Use above code
Working fine for me.