loadView加载(变换成ScrollView)

/**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);

    }

}

posted @ 2015-11-25 11:41  TheYouth  阅读(375)  评论(0编辑  收藏  举报