Uibutton Subclass @Ibaction Not Working

why is my custom UIButton subclass not triggering touch up IBAction?

ah ok, figured it out. in my custom button initializer I added a subview which, by default, had userInteractionEnabled set to true. setting userInteractionEnabled = true on my custom button object and userInteractionEnabled = false on my view before adding it as a subview allows my custom button to capture the touch and handle it properly rather than the view capturing the touch

touch up inside (@IBAction) does not work with UIButton subclass

You broke UIButton by overriding beginTracking() and always returning false. This brainwashes the button into thinking it's never being clicked.

What was your intent there? In any case, return true there and your code will fire the @IBAction.

EDIT: You're overthinking the issue by using a low-level method meant for highly customized behavior such as non-rectangular buttons. You just need:

How to use UIButton as Toggle Button?

IOS 9 - UIButton on subview does not fire IBAction outlet

Daniel.
Your issue is that you don't add your view controller as child to view controller which operates with Koloda. In the result your vc.view is shown, because Koloda retains it, but nobody retains your view controller, so you are losing important lifecycle methods and it gets deallocated.

The approach your trying to use is called Container View Controller. Apple has suggestion about its implementation here: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html

Simple implementation here:

- (void) displayContentController: (UIViewController*) content {
[self addChildViewController:content];
content.view.frame = [self frameForContentController];
[self.view addSubview:self.currentClientView];
[content didMoveToParentViewController:self];
}

Custom UIButton fires IBAction once, then never again

You say that "ripple is a subview added to container, container is a view added to RippleButton"... are you removing that container after the "ripple" effect? Maybe that's getting the touch event.

Swift: UIButton not working though connected and other button is working

Got it. After adding height and width constraints to the sub view being superior to the button, it worked. It appears as if otherwise the subview collapses with regards to user interaction, however, still shows the embedded button.



Related Topics



Leave a reply



Submit