0
votes

I'm implementing a custom UIView with nested UIScrollView.

initialization looks like:

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 10, 252, 200)];        
        scrollView.backgroundColor = [UIColor clearColor];
        scrollView.contentSize = CGSizeMake(500, 400); 
        scrollView.userInteractionEnabled = YES;
        scrollView.pagingEnabled = NO;
        scrollView.scrollEnabled = YES;
        scrollView.clipsToBounds = YES;
        [scrollView setAutoresizesSubviews:YES];
        [scrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
        [scrollView setDirectionalLockEnabled:NO];
        [scrollView setDelegate:self];

        [scrollView setShowsHorizontalScrollIndicator:YES];
        [scrollView setShowsVerticalScrollIndicator:YES];
        [scrollView setBounces:YES];
        [scrollView setAlwaysBounceHorizontal:NO];
        [scrollView setAlwaysBounceVertical:NO];
        [scrollView setBouncesZoom:YES];
        [scrollView setDelaysContentTouches:YES];
        [scrollView setCanCancelContentTouches:YES];

        [scrollView setMaximumZoomScale:1];
        [scrollView setMinimumZoomScale:1];
        [scrollView setOpaque:YES];

        [self addSubview:scrollView];                            
    }
    return self;
}

in controller:

CustomView *customView = [[CustomView alloc] initWithFrame:CGRectMake(0, 100, 320, 200)];
[self.view addSubview:cut];

Problem: scroll view scroll only in up direction (when i drag finger down), when i try to scroll left, right or down there is no action

what i am doing wrong?

1

1 Answers

0
votes

Many properties you set are the same as the default value. You'll find the default values here: UIScrollView Class Reference

My suggestion would be to delete the properties which have already the default value. Especially the properties for scrolling.

[scrollView setShowsHorizontalScrollIndicator:YES];
[scrollView setShowsVerticalScrollIndicator:YES];
[scrollView setBounces:YES];
[scrollView setAlwaysBounceHorizontal:NO];
[scrollView setAlwaysBounceVertical:NO];
[scrollView setBouncesZoom:YES];
[scrollView setDelaysContentTouches:YES];
[scrollView setCanCancelContentTouches:YES];