我担心我的信息过载了。我的iPad应用程序(iOS 5.1)有一个教程页面。我正在尝试以这样一种方式创建教程页面,即用户可以在图像上向左或向右滑动(显示教程信息)以移动到教程的上一部分或下一部分。
_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];
但这显然不符合我的意愿。我现在可以滑动页面来移动图像,但我想滑动图像(这将占据整个屏幕并将其扫描到下一个图像。作为一个注释,这必须以编程方式完成,而不是通过故事板国际文凭组织。
实现这一目标的最佳方法是什么?
谢谢