1

I'm afraid I'm having information overload. I have a Tutorial Page for my iPad app (iOS 5.1). I'm trying to create the tutorial page in such a way that the user can swipe left or right on an image (which shows tutorial information) to move to the previous or next section of the tutorial.

_scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 768, 704)];
_scrollview.backgroundColor = [UIColor grayColor];
_scrollview.contentSize = CGSizeMake(700, 700);
_scrollview.minimumZoomScale = 1.0;
_scrollview.maximumZoomScale = 1.0;
_scrollview.pagingEnabled = YES;

_imgViews = [NSMutableArray arrayWithCapacity:NUMPICS];
for (int i = 0; i < NUMPICS; i++) {
    NSString *imgPath = [NSString stringWithFormat:@"%@/%d.png", [[NSBundle mainBundle] resourcePath], i+1];
    UIImage *image = [UIImage imageWithContentsOfFile:imgPath];
    UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
    imgView.frame = CGRectOffset(imgView.frame, 10, 10);
    [_imgViews addObject:imgView];
    [_scrollview addSubview:imgView];
}
[_scrollview bringSubviewToFront:[_imgViews objectAtIndex:0]];

UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeNext:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
[_scrollview addGestureRecognizer:swipeLeft];

UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipePrev:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[_scrollview addGestureRecognizer:swipeRight];

[self.view addSubview:_scrollview];

_pageview = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 654, 768, 50)];
_pageview.numberOfPages = [_imgViews count];
_pageview.currentPage = 0;
_pageview.backgroundColor = [UIColor grayColor];
_pageview.userInteractionEnabled = NO;
[self.view addSubview:_pageview];

But this obviously doesn't do what I'd like. I can now swipe the page to move the image, but I'd like to swipe the image (which will take up the entire screen and have it sweep to the next image. As a note, this must be done programmatically, not through storyboard of the IB.

What is the best way to accomplish this?

Thank you

tophersmith116
  • 432
  • 1
  • 5
  • 19
  • This might be what you are looking for. http://stackoverflow.com/questions/1816144/uipagecontrol-help – Sohan Apr 23 '12 at 12:20
  • it turns out my code has violated a few things. the push/pop on the main vc (it's a master/detail) so I had to remove it. it wouldn't respond to any of the functions it should have. Thanks for your help, but it turns out I found a way to confuse Apple. – tophersmith116 Apr 25 '12 at 19:35

0 Answers0