//
//  UIScrollView+Customized.m
//  DingDCommunity
//
//  Created by JianjiYuan on 14-5-3.
//  Copyright (c) 2014年 JianjiYuan. All rights reserved.
//

#import "UIScrollView+Customized.h"

@implementation UIScrollView (Customized)

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesBegan:touches withEvent:event];
    [super touchesBegan:touches withEvent:event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesMoved:touches withEvent:event];
    [super touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesEnded:touches withEvent:event];
    [super touchesEnded:touches withEvent:event];
}

- (void)autoFitHeightOfSubView
{
    CGFloat maxYForScroll = 0.0f;
    for (UIView *subView in self.subviews) {
        CGFloat maxYOfSubView = CGRectGetMaxY(subView.frame);
        if (maxYOfSubView > maxYForScroll) {
            maxYForScroll = maxYOfSubView+10;
        }
    }
    maxYForScroll = maxYForScroll>CGRectGetHeight(self.frame)?maxYForScroll:CGRectGetHeight(self.frame);
    
    [self setContentSize:CGSizeMake(CGRectGetWidth(self.frame), maxYForScroll)];
}

@end
