Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIScroll查看下一个上一个按钮_Iphone_Objective C_Image_Uiscrollview - Fatal编程技术网

Iphone UIScroll查看下一个上一个按钮

Iphone UIScroll查看下一个上一个按钮,iphone,objective-c,image,uiscrollview,Iphone,Objective C,Image,Uiscrollview,我有一个滚动视图。在滚动视图中,我有图像视图。我想通过点击按钮转到下一个和上一个图像。在下文中,它只对三个阵列图像起作用,但不超过这一点,因此如何对所有图像起作用。我有70个图像阵列 - (IBAction)nextButtonAction { int arraycount = [appDelegate.articles count]; NSLog(@" arraycount : %d", arraycount);

我有一个滚动视图。在滚动视图中,我有图像视图。我想通过点击按钮转到下一个和上一个图像。在下文中,它只对三个阵列图像起作用,但不超过这一点,因此如何对所有图像起作用。我有70个图像阵列

        - (IBAction)nextButtonAction {

               int arraycount = [appDelegate.articles count];

               NSLog(@" arraycount : %d", arraycount);

               NSLog(@" [pageControl currentPage] : %d", [pageControl currentPage]);

               for (int nextIndex = [pageControl currentPage]; nextIndex < (arraycount-1); nextIndex++) {

               if ( self.scrollView.contentOffset.x <= self.scrollView.frame.size.width ) {

                CGRect frame;
                frame.origin.x = self.scrollView.contentOffset.x +     self.scrollView.frame.size.width;
                frame.origin.y = 0;
                frame.size = self.scrollView.frame.size;
                [self.scrollView scrollRectToVisible:frame animated:YES];
                pageControlBeingUsed = YES;
                }  
            }

        }


-(IBAction)previousButtonAction{

          if ( self.scrollView.contentOffset.x >= self.scrollView.frame.size.width ) {
          CGRect frame;
          frame.origin.x = self.scrollView.contentOffset.x -     self.scrollView.frame.size.width;
          frame.origin.y = 0;
          frame.size = self.scrollView.frame.size;
          [self.scrollView scrollRectToVisible:frame animated:YES];
          pageControlBeingUsed = YES;
          } 

   }
    - (IBAction)nextButtonAction {

        int arraycount = [appDelegate.articles count];

        if ( self.scrollView.contentOffset.x < (self.scrollView.frame.size.width *arraycount) ) {

            CGRect frame;
            frame.origin.x = self.scrollView.contentOffset.x +     self.scrollView.frame.size.width;
            frame.origin.y = 0;
            frame.size = self.scrollView.frame.size;
            [self.scrollView scrollRectToVisible:frame animated:YES];
            pageControlBeingUsed = YES;

        }

    }
- (IBAction)btn_NextPressed:(id)sender
{
    CGFloat pageWidth = self.scrollview.frame.size.width;
    intPage = (NSInteger)floor((self.scrollview.contentOffset.x * 2.0f + pageWidth) / (pageWidth * 2.0f));
   [self.scrollview setContentOffset:CGPointMake(self.scrollview.contentOffset.x + self.scrollview.contentSize.width/numberOfPages ,0) animated:YES];
}

- (IBAction)btn_PrevPressed:(id)sender
{
    CGFloat pageWidth = self.scrollview.frame.size.width;
    intPage = (NSInteger)floor((self.scrollview.contentOffset.x * 2.0f + pageWidth) / (pageWidth * 2.0f));
    [self.scrollview setContentOffset:CGPointMake(self.scrollview.contentOffset.x - self.scrollview.contentSize.width/numberOfPages ,0) animated:YES];
}