2

I would like to kind of recreate the layout of the app I have pictures of below. There is a navigation bar at the top, with paged content in the middle. I have looked in to several ways of how to page content, including UIScrollViews, UIPageControl, and PageViewControllers, but I cant seem to quite be able to recreate this layout. Most tutorials that I find aren't updated for iOS7 either. All input is greatly appreciated.

Pictures:

enter image description here enter image description here

Isuru
  • 30,617
  • 60
  • 187
  • 303
SuperAdmin
  • 538
  • 2
  • 7
  • 20
  • I do this in iOS7 using a UIPageControl and a scrollview. Just look at when the scrollview has finished decelerating and see if paging has occurred or not – Jason Renaldo Mar 04 '14 at 21:35
  • @JayMorgan All UIPageControl tutorials I found use XIB files. I want to use a storyboard, but I cant find tutorials with all these criteria. – SuperAdmin Mar 04 '14 at 21:38
  • You can still use XIB files along with Storyboard. The XIB files will contain the UIView objects that will act as your pages. – hgwhittle Mar 04 '14 at 21:41
  • @hw731 could you provide me with an example or online tutorial? I am new to iOS programming and am not quite sure how I would go about that. – SuperAdmin Mar 04 '14 at 21:43
  • @iOSNoob: you can use https://github.com/virus108/TKScroller lib for that. –  Mar 06 '14 at 09:34

3 Answers3

6

Here's a few resources to help get you started.

Apple's documentation has a very good example of how to implement a paging scroll view using a UIPageViewController, see the Photo Scroller sample code here. I would suggest starting there.

I also have some code on github that modifies Apple's Photo Scroller example to load the UIPageViewController inside a UIViewController subclass.

This is a good tutorial by the Ray Wenderlich team on how to set up a paging scrollview: How To Use UIScrollView to Scroll and Zoom Content

I've also answered a few other questions about paging scroll views that you might find useful. See here, here, here and here.

Community
  • 1
  • 1
Steph Sharp
  • 11,462
  • 5
  • 44
  • 81
2

Just have an int instance variable set initially to 0. If shouldn't matter if you use .xibs or storyboard, the concept remains the same. If you want to lay absolutely everything out in IB look here: How to add objects to a UIScrollView that extend beyond UIView from Storyboard?

To know when paging occurred use this:

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    CGFloat pageWidth = self.scrollview.bounds.size.width;
    curIndex = floor((self.scrollview.contentOffset.x - pageWidth / 2) / pageWidth) + 1;

    if (curIndex == lastIndex) return;

    lastIndex = curIndex;
    //increment pager and do whatever else...
}
Community
  • 1
  • 1
Jason Renaldo
  • 2,802
  • 3
  • 37
  • 48
0

Here's a great tutorial on doing paged scrollView!

And BTW there's nothing special in iOS7 about this. At least nothing I can think of.

AXE
  • 8,335
  • 6
  • 25
  • 32