IPhone - conflict between UIScrollView and UIDatePicker with scrolling: one intervenes in the second

I have a UIDatePicker inside a UIScrollView. But UIDatePicker does not respond to scrolling. This is a scroll that scrolls. While reading some online documents, I set the β€œDelay Content Touches” to NO, now I can see the datepicker launching a small scroll, but still there is a scrollview that takes the final word. I have a place on the screen where the user can tap to scroll the view. So, how can I separate the two kinds of scrolls and make the datepicker scroll in the usual way?

thanks for the help

+3
source share
2 answers

: http://www.alexc.me/uiscrollview-and-uidatepicker/153/

:

UIScrollViewBreaker.h

@interface UIScrollViewBreaker : UIScrollView {

}

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view;
- (BOOL)touchesShouldCancelInContentView:(UIView *)view;

@end

UIScrollViewBreaker.m

@implementation UIScrollViewBreaker


- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {

    if ([view isKindOfClass:[UIDatePicker class]] || [@"UIPickerTable" isEqualToString:[[view class] description]] ) {
        //|| [view isKindOfClass:[UIPicker class]]
        return YES;
    }
    return [super touchesShouldBegin:touches withEvent:event inContentView:view];
}

- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
    if ([view isKindOfClass:[UIDatePicker class]] || [@"UIPickerTable" isEqualToString:[[view class] description]] ) {
        return NO;
    }
    return [super touchesShouldCancelInContentView:view];
}


@end

IB UIScrollView UIScrollViewBreaker.

.

- , .

+5

@Oliver , .

http://github.com/webartisan/TPKeyboardAvoiding

Love Stackoverflow!!!!

.

+1

Source: https://habr.com/ru/post/1785821/


All Articles