Search code examples
iosiphoneuiviewuiscrollviewtouches

My UIScrollView (containing some UIControls) doesn't scroll anymore in iOS 8


In my app I have made a calendar which basically consists in a UIScrollView containing some cells (custom UIControl) for each day, a top header containing some labels (Mon, Tue, Wed...), and obviously some separators (UIView of 1px thickness).

Everything worked fine on iOS 7, I was able to select the cells by pressing them (I use the UIControlEventTouchUpInside event to select them), and to drag the paged scrollview to display the previous or next month.

But since I've switched to iOS 8, and downloaded Xcode 6, it doesn't work anymore. In fact I can still select the cells, but the scrollview doesn't scroll (except if I drag it from the header or a separator, which are basic UIView without any touch event management).

Il I start dragging the scrollview from a cell, it just stay fixed.

I didn't change anything, so I don't understand why it doesn't work anymore...

Please help me!! :)

Thanks a lot

PS: I'm french, sorry for my bad english


Solution

  • EDIT: with iOS 8.1 the behavior seems to be similar to behavior before iOS 8.0, so Apple might have 'fixed' it. So the answer below is not needed any more.


    There has been a change in iOS 8, as far as I can see, which influences the handling of UIScrollview. UIScrollView does not track content touches any more in case of an UIControl.

    One thing I did, is to subclass UIScrollView and overwrite touchesShouldCancelInContentView

    - (BOOL) touchesShouldCancelInContentView:(UIView *)view {
        return YES;
    }
    

    See also https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/index.html

    Return Value: YES to cancel further touch messages to view, NO to have view continue to receive those messages. The default returned value is YES if view is not a UIControl object; otherwise, it returns NO.