Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7043903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:20:45+00:00 2026-05-28T02:20:45+00:00

I want to do swipe gesture to slide the UIView continuously and getting data

  • 0

I want to do swipe gesture to slide the UIView continuously and getting data from it. Consider each word in each UIView. I stored data in an array and printed in label of UIView while transition. But when I try to swipe after shown all data program get stopped working. My project showing no errors. Please help me with it.

This is my array:

addArray = [[NSMutableArray alloc]initWithCapacity:4];
[addArray insertObject:@"10" atIndex:0];
[addArray insertObject:@"20" atIndex:1];
[addArray insertObject:@"30" atIndex:2];
[addArray insertObject:@"40" atIndex:3];

flippedArray = [[NSMutableArray alloc] initWithCapacity:4];
[flippedArray insertObject:@"100" atIndex:0];
[flippedArray insertObject:@"200" atIndex:1];
[flippedArray insertObject:@"300" atIndex:2];
[flippedArray insertObject:@"400" atIndex:3];

This is my gesture recognizer coding:

-(void)swipegesture:(UISwipeGestureRecognizer *)recognizer{

    CGPoint location = [recognizer locationInView:additionalView];   
    if (recognizer.direction==UISwipeGestureRecognizerDirectionLeft) 
    {
        if (increment<[addArray count]) 
        {
            NSLog(@"%d",[addArray count]);
            increment++;
            if(increment==[addArray count])
            {
                NSLog(@"Fail");
                //[recognizer requireGestureRecognizerToFail:swipeGesture];
                [recognizer setEnabled:NO];
            }
            else
            {
                additionalLabel.text=[[NSString alloc] initWithFormat:@"%@",
                                         [addArray objectAtIndex:increment]];
                flippedLabel.text = [[NSString alloc] initWithFormat:@"%@",
                                         [flippedArray objectAtIndex:increment]];
                NSLog(@"increment %d",increment);
                [UIView animateWithDuration:0.55 animations:^{
                    [UIView setAnimationDelay:0.2];
                }];
                CATransition *animation = [CATransition animation];
                [animation setType:kCATransitionPush];
                [animation setSubtype:kCATransitionFromRight];
                [animation setTimingFunction:[CAMediaTimingFunction
                               functionWithName:kCAMediaTimingFunctionDefault]];
                [animation setSpeed:0.4];
                [[additionalView  layer] addAnimation:animation forKey:nil];
            }
        }
    }
    else if(recognizer.direction==UISwipeGestureRecognizerDirectionRight)
    {
        if (increment>=0 && increment<[addArray count]) 
        {
            increment--;
            if(increment>[addArray count])
            {
                additionalLabel.text=[[NSString alloc]initWithFormat:@"%@",
                                         [addArray objectAtIndex:increment]];
                flippedLabel.text=[[NSString alloc]initWithFormat:@"%@",
                                      [flippedArray objectAtIndex:increment]];
                NSLog(@"Decrement %d",increment);
                [UIView animateWithDuration:0.55 animations:^{
                    [UIView setAnimationDelay:0.2];
                }];
                CATransition *animation = [CATransition animation];
                [animation setType:kCATransitionPush];
                [animation setSubtype:kCATransitionFromLeft];
                [animation setTimingFunction:[CAMediaTimingFunction 
                               functionWithName:kCAMediaTimingFunctionDefault]];
                [animation setSpeed:0.4];
                [[additionalView layer] addAnimation:animation forKey:nil];
            }
        }
    }
}

There is a problem while increment only. I got NSLog print as FAIL. But I dont how to stop gesture recognizer if it reaches the value as [addArray count].

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:20:45+00:00Added an answer on May 28, 2026 at 2:20 am

    I would recommend incrementing or decrementing your index value (which you named increment) before the validity check, and if it is not valid reverse your action in an else. Like so:

    if (recognizer.direction==UISwipeGestureRecognizerDirectionLeft) 
    {
        increment++;
    
        if (increment<[addArray count]) 
        {
            // Your code
        }
        else
        {
            increment--; // The increment would pass the range of the array, set it back.
        }
    }
    

    And likewise for the other direction.

    EDIT: To clarify, the original problem is that you check to make sure your index is valid, but, by incrementing after the check you end up making it invalid. Using your example, when the increment is 3 (the highest index of your array) it is in fact less than the array’s count, which is 4. You then increment your index to 4, which would be out of bounds, or, in your case, fall into that if statement (which will no longer be needed using the suggestion) and log your FAIL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement the handling of an additional swipe gesture in my UITableViewController.
I want to swipe images in windows phone 7. Where do I begin from?
I want my UIImageView to detect both Tap and Swipe gesture. I've coded the
I got 3 textviews which i want to move on swipe. How do i
I want to create a notification that can be cleared. e.g. Swipe right on
I managed to detect when I swipe a certain image. Now I want the
What I would like to do is to detect a swipe gesture followed by
Actually i want to implement swipe left and right in UIScrollview. i have scrollview
Hej folks, I got an UIView in my application and want to implement kind
I want to implement all possible Gesture recognizers on image,like rotate gesture recognizer zoom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.