I have a UIScrollView that doesn't scroll at all. If I turn on bouncing, I can scroll far enough to the sides to see that there is content outside the view, but it drops back to the origin when I release. I have paging enabled, but I get the same behavior if I disable it. I have disabled auto-layout. In IB, scrollView is in the MainViewController correctly associated with the IBOutlet, as shown below.
@interface MainViewController () @property (strong, nonatomic) IBOutlet UIScrollView *scrollView; @end @implementation MainViewController - (void)viewDidLoad { [super viewDidLoad]; for (int i = 0; i < 3; i++) { CGRect frame; frame.origin.x = self.scrollView.frame.size.width * i; frame.origin.y = 0; frame.size = self.scrollView.frame.size; // I might be doing this wrong, but it returns a PosterView object just like I want it to. NSArray *view = [[NSBundle mainBundle] loadNibNamed:@"posterView" owner:self options:nil]; [[view objectAtIndex:0] setFrame:frame]; [self.scrollView addSubview:[view objectAtIndex:0]]; } self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * 3, self.scrollView.frame.size.height); }
If I use this method, it scrolls correctly.
-(void)scrollToPage:(NSInteger)page{ float pageWidth = [self.scrollView frame].size.width; [self.scrollView setContentOffset:CGPointMake(page*pageWidth,0) animated:YES]; }
I tried to implement UIScrollViewDelegate and override scrollViewDidScroll , but it is never called (unless I have permission to roll back, as I mentioned earlier).
source share