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
Skvideonode Only on a Small Part of Scnsphere
Return in Function Without Return Value in Swift
Setcollectionviewlayout' Animation Broken When Also Changing Collection View Frame
Disable Vertical Scroll in Uiscrollview Swift
Circle Image in Cell Imageview and How to Resize It
How to Change Button Text Size in iOS 8 Swift
How to Convert Date (Without Knowing the Kind) to String
How to Change Searchbar Border Color
Output Video Size Huge Using Hevc Encoder on iOS
How to Make Synchronous Operation with Asynchronous Callback
Swift - Parse a String Which Contains a Url
iOS Keyboard Active But Invisible When Uisearchbar Is Tapped
How to Get the User "Name" Using Swift
Hls Metadata Id3 Tag Not Working
Read Uiapplicationlaunchoptionsurlkey in Swift
Convert Urlrequest to Nsmutableurlrequest