/**loadView加载,将系统的view变换成ScrollView*/
- (void)loadView{
[super loadView];
UIScrollView *mainScroll = [[UIScrollView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
mainScroll.scrollEnabled = YES;
mainScroll.contentSize = CGSizeMake(0, VIEW_MAIN_SCREEN_HEIGHT + 40);
mainScroll.userInteractionEnabled = YES;
mainScroll.showsVerticalScrollIndicator = NO;
mainScroll.multipleTouchEnabled = YES;
mainScroll.delegate = self;
self.view = mainScroll;
}
//然后在拖拽完成后,增加它的高度,以最后一个控件最大的Y值加上一定间隙,思路是判断view上最下面的view是否大于scrollView的高度,如果大于让滚动,并且scrollView的contentSize的height加上一定间隙
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
CGFloat DeleteY = CGRectGetMaxY(self.OrderDeleteBtn.frame);
if (DeleteY > scrollView.frame.size.height) {
scrollView.scrollEnabled = YES;
}else{
scrollView.scrollEnabled = NO;
}
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
CGFloat DeleteY = CGRectGetMaxY(self.OrderDeleteBtn.frame);
if (DeleteY > scrollView.frame.size.height) {
scrollView.contentSize = CGSizeMake(Screen_size.width, CGRectGetMaxY(self.OrderDeleteBtn.frame)+10);
}else{
scrollView.contentSize = CGSizeMake(Screen_size.width,200);
}
}