Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

straber

macrumors member
Original poster
Jul 3, 2012
60
0
I want to have 2 views side by side in a scroll view and have the scroll view always scroll one of the views to fully visible so you can never have the scroll view stop with part of one view visible and part of the other visible. I tried doing this with:

Code:
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    if (scrollView == self.scrollView) {
        CGFloat location = scrollView.contentOffset.x;
        if (location <= self.alarmMenuView.frame.size.width / 2) {
            [UIView animateWithDuration:0.3 animations:^ {
                [scrollView setContentOffset:CGPointMake(0, 0) animated:NO];
            }];
        }
        else {
            [UIView animateWithDuration:0.3 animations:^ {
                [scrollView setContentOffset:CGPointMake(self.alarmMenuView.frame.size.width, 0) animated:NO];
            }];
        }
    }
}

but I can still end up in a state where part of each view is visible. How can I make it so only one view is visible at a time?

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.