material-components-ios icon indicating copy to clipboard operation
material-components-ios copied to clipboard

[Cards] Adding touchUpInside event to MDCCard in the storyboard does nothing when the card is touched

Open bjimenezned opened this issue 5 years ago • 7 comments

Adding a touchUpInside event to a MDCCardView in the storyboard is not working

Reproduction steps

Steps to reproduce the behavior:

  1. Add an UIView of custom class MDCCard in a storyboard
  2. 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

bjimenezned avatar Feb 20 '19 15:02 bjimenezned

The title doesn't have a [Component] prefix.

Thank you @bjimenezned .

We'll attempt to repro and add to Dragons.

ianegordon avatar Feb 20 '19 19:02 ianegordon

Sounds similar to https://github.com/material-components/material-components-ios/issues/5513

romoore avatar Feb 20 '19 20:02 romoore

Same result even after setting 'isUserInteractionEnabled = true ' or ' interactable = ON' on MDCCard . It still does not respond to click events

buelersandra avatar Oct 28 '19 22:10 buelersandra

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 avatar Dec 18 '20 10:12 mehulparmar4ever

@mehulparmar4ever , doesn't for me.

ekrivenja avatar Dec 19 '20 18:12 ekrivenja

I am using it in UITableView & Inside UITableviewCell,I have drag & drop UIView & Set Class "MDCCard" & Use above code

Working fine for me.

mehulparmar4ever avatar Dec 21 '20 15:12 mehulparmar4ever