UIButton Doesn't allow UIScrollView to scroll

uibutton toggle
swift highlight button when pressed
uibutton states
uibutton selected and unselected swift
uibutton momentary
uiswitch
swift change button color when pressed
swift uibutton toggle

I have many UIButtons within a UIScrollView. Those UIButtons have actions attached to them in Touch Down Repeat. My problem is my scroll view doesn't scroll when I touch a button then scroll, but it works fine if I touch outside of the button.

How can I allow my scroll view to scroll even though a button is pressed?

As long as you have the Cancellable Content Touches in Interface Builder set it should work. You can also set it in code:

scrollView.canCancelContentTouches = YES;

UIButton: title doesn't show when …, UIButton: title doesn't show when setting background images for states. With the latest Xcode update (Xcode v7.1 beta 3), UIButton titles stopped showing up� Well, consider that the UIButton doesn’t know your code. It doesn’t know you have that function, and moreover, it can’t access your function directly! You need a way to tell the button what to do, and you do that by giving it a target and an action.

So view.canCancelContentTouches = YES works OK if you don't also have delaysContentTouches set to YES. If you do though, the buttons won't work at all. What you need to do is subclass the UIScrollView (or UICollectionView/UITableView) and implement the following:

Objective-C

- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
    if ([view isKindOfClass:UIButton.class]) {
        return YES;
    }
    return [super touchesShouldCancelInContentView:view];
}

Swift 2

override func touchesShouldCancelInContentView(view: UIView) -> Bool {
    if view is UIButton {
        return true
    }
    return super.touchesShouldCancelInContentView(view)
}

UIButton doesn't show highlight on tap in iOS, When we touch on the button, action method will be called but there is no visible state changes (Highlighted state) is happening for the button. The Title menu works fine, but it doesn't have a event system or canvas group. I tried copying all the components from the Title menu into that game scene but then they stopped working. __RIPstER__ , Jan 2, 2018

Use a UITapGestureRecognizer with delaysTouchesBegan as a property set to true.

UIButton doesn't adjust its image automatically when pressed, NavigationController.InteractivePopGestureRecognizer.DelaysTouchesEnded = false; But it still doesn't work, I even tried putting my button on a new view� Tim’s answer is correct, however I wanted to add another suggestion, because in my case there was a simpler solution altogether. I was looking to set the UIButton image insets because I didn’t realize that I could set the content mode on the button’s UIImageView, which would have prevented the need to use UIEdgeInsets and hard-coded values altogether.

Making a simple toggle button with UIButton, It's actually pretty straightforward to turn a UIButton into a toggle button. This works ok for the 'unselected' state, but doesn't look quite right for� UIButton has nice option to set different images for different control states but there is not same feature for background colors. So one of solutions is to add extension which will generate images from color and apply them to button.

UIButton: Padding Between Image and Text, Pop quiz: in a UIButton, how do you set a padding of 10pt between of the titleEdgeInsets since we have to make sure the button doesn't get� Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.

Setting UIButton Title and Title Color "The Right Way" in Swift 3 , Every time I set a UIButton color or title I fail at first because I try to do the following: //This is incorrect, don't do this let button = UIButton()� Employment Development Department. By Fax or Mail. Reopen your UI claim by accessing the paper Unemployment Insurance Application.For faster and secure processing, fax the completed application to the number listed on the form.

Comments
  • Wow, a simple checkbox fixes my issue. Thanks!
  • No problem. Also check out the Delay Content Touches property and docs, may be relevant to what you're doing as well.
  • Note that you also need to subclass UIScrollView to really make it work. See stackoverflow.com/a/3550157/908621 for details
  • Above comment with link is vital to correctly handle this situation.
  • What if ScrollView is added on the cell of UITableView? Will it work in thatb case? I don't think so