Check if a UIScrollView reached the top or bottom

Implement the UIScrollViewDelegate in your class, and then add this: -(void)scrollViewDidScroll: (UIScrollView*)scrollView { float scrollViewHeight = scrollView.frame.size.height; float scrollContentSizeHeight = scrollView.contentSize.height; float scrollOffset = scrollView.contentOffset.y; if (scrollOffset == 0) { // then we are at the top } else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight) { // then we are at the end } } … Read more

Paging UIScrollView in increments smaller than frame size

Try making your scrollview less than the size of the screen (width-wise), but uncheck the “Clip Subviews” checkbox in IB. Then, overlay a transparent, userInteractionEnabled = NO view on top of it (at full width), which overrides hitTest:withEvent: to return your scroll view. That should give you what you’re looking for. See this answer for … Read more

How to Make the scroll of a TableView inside ScrollView behave naturally

The solution to simultaneously handling the scroll view and the table view revolves around the UIScrollViewDelegate. Therefore, have your view controller conform to that protocol: class ViewController: UIViewController, UIScrollViewDelegate { I’ll represent the scroll view and table view as outlets: @IBOutlet weak var scrollView: UIScrollView! @IBOutlet weak var tableView: UITableView! We’ll also need to track … Read more

UIScrollView: paging horizontally, scrolling vertically?

You’re in a very tough situation, I must say. Note that you need to use a UIScrollView with pagingEnabled=YES to switch between pages, but you need pagingEnabled=NO to scroll vertically. There are 2 possible strategies. I don’t know which one will work / is easier to implement, so try both. First: nested UIScrollViews. Frankly, I’m … Read more

How to disable horizontal scrolling of UIScrollView?

You have to set the contentSize property of the UIScrollView. For example, if your UIScrollView is 320 pixels wide (the width of the screen), then you could do this: CGSize scrollableSize = CGSizeMake(320, myScrollableHeight); [myScrollView setContentSize:scrollableSize]; The UIScrollView will then only scroll vertically, because it can already display everything horizontally.

Getting the current page

There is no UIScrollView property for the current page. You can calculate it with: int page = scrollView.contentOffset.x / scrollView.frame.size.width; If you want to round up or down to the nearest page, use: CGFloat width = scrollView.frame.size.width; NSInteger page = (scrollView.contentOffset.x + (0.5f * width)) / width;