0

I want to add three views in a UIViewController,

  1. UIImageView
  2. Scrollable Segment control (HMSegmentedControl)
  3. UIViews (or) UITableviewCells

it looks like this, enter image description here

When the whole view scrolls the segment control should pin at the top of the screen (like header in UITableview).

My code

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

if ((long)scrollView.tag == 10) {

    // Main scrollview
    if (self.lastContentOffset >= scrollview.contentOffset.y) {
        NSLog(@"Down");
        if (scrollview.contentOffset.y < 158.0f) {
            [scrollview setContentOffset:CGPointMake(scrollview.contentOffset.x, scrollview.contentOffset.y)];
            [matchInfoTable setScrollEnabled:NO];
            [scrollview setScrollEnabled:YES];
        }
    } else if (self.lastContentOffset <= scrollview.contentOffset.y) {
        NSLog(@"Up");
        NSLog(@"%f",scrollview.contentOffset.y);
        if (scrollview.contentOffset.y > 138.0f) {
            [scrollview setScrollEnabled:NO];
            [matchInfoTable setScrollEnabled:YES];
        }

        if (scrollview.contentOffset.y >= 163.0f) {
            [scrollview setContentOffset:CGPointMake(scrollview.contentOffset.x, 163.0f)];
            [scrollview setScrollEnabled:NO];
            [matchInfoTable setScrollEnabled:YES];
        }   
    }
    self.lastContentOffset = scrollview.contentOffset.y;

    NSLog(@"LastOffset :: %f",self.lastContentOffset);

} else if (scrollView.tag == MATCH_INFO) {
    // match info table

    if (scrollView.contentOffset.y == 0) { // TOP
        [scrollview setContentOffset:CGPointMake(scrollview.contentOffset.x, scrollview.contentOffset.y)];
        [matchInfoTable setScrollEnabled:NO];
        [scrollview setScrollEnabled:YES];
    }
}
}

In this code when the segment control pin at the top. The below view is not scrolling continuously. I need to trigger its scrolling again.

All answers are appreciated!!

Maniganda saravanan
  • 2,188
  • 1
  • 19
  • 35

1 Answers1

0

I think better you should use UIPageViewController and put inside all tableviews, then you can detect swipes and change tabs.

Also you can use UISwipeGestureRecognizer and detect left and right swipes described in this post left and right swipes

Community
  • 1
  • 1
Vadim Kozak
  • 420
  • 3
  • 11