Search code examples
iosuiscrollviewscrolldirection

Scrollview with paging enabled scrolling from left to right - iOS


I have read the apple documentation concerning UIScrollView but cannot reach to a clear idea about setting the scrollview with paging enabled scrolling direction starts from Left to RIGHT to suite ARABIC content ... any ideas please ??


Solution

  • I solved the problem by using UISlider by setting the slider to the last page of my scrollview in viewdidload

    CGPoint pnt = CGPointMake(19 * self.scrollView.frame.size.width , 0) ;
        [self.scrollView setContentOffset:pnt animated:YES];
    
        CGFloat pageWidth = self.scrollView.frame.size.width;
        NSInteger page = (NSInteger)floor((self.scrollView.contentOffset.x * 2.0f + pageWidth) / (pageWidth * 2.0f));
        [slider setValue:page];
    

    Now I can scroll by tap and scroll the appropriate direction for arabic content :)

    note : 19 is the number of pages in scrollview which equals to no of images - 1 .