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 4063418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:43:23+00:00 2026-05-20T15:43:23+00:00

I have been trying to build a custom uitableview swipe. I am successful in

  • 0

I have been trying to build a custom uitableview swipe. I am successful in that. I also wanted to add a uiview as a subview to the tablecell when it encounters touchesMoved. And when i am trying to move the tablecell, I wanted the uiview being appended to be stationary. For that I am also making it move in opp direction (as suggested by one of the answers in StackOverflow). But it is not looking to be stationary. The subview is also moving along with the cell. Please help me find out where i am going wrong? The code is as follows:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{
UITableViewCell * cell = (UITableViewCell *)[self cellForRowAtIndexPath:[self indexPathForRowAtPoint:gestureStartPoint]];
isTouchesMoved=YES;

if ([self supportsSwipingForCellAtPoint:gestureStartPoint])
{

    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(highlightTouchedRow) object:nil];

    UITouch * touch = [touches anyObject];
    CGPoint currentPosition = [touch locationInView:self];
    CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
    CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);
    if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance)
    {
        tempView=[self addnewViewatPoint:touches withEvent:event];
        [cell addSubview:tempView];
        [self setScrollEnabled:NO];
        CGPoint loc = [touch locationInView:self];
        CGPoint prevloc = [touch previousLocationInView:self];
        if(moved==TRUE)
        {
            prevLoc=cell.frame;
            prevLocBack=tempView.frame;
            moved=FALSE;
        }
        CGRect myFrame = cell.frame;
        CGRect backFrame = tempView.frame;
        CGFloat deltaX = loc.x - prevloc.x;
        if(gestureStartPoint.x>currentPosition.x)
        {
            NSLog(@"You have swiped left");
            CGFloat movedDistance=gestureStartPoint.x-currentPosition.x;
            NSLog(@"The movedDistance is %f",movedDistance);
            if(movedDistance<=160)
            {
                myFrame.origin.x += deltaX;
                backFrame.origin.x-=deltaX;
                NSLog(@"The backgroundViewframe position, frameposition is %f and %f",fabsf(backFrame.origin.x),fabsf(myFrame.origin.x));
            }
            [tempView setFrame:backFrame];
            [cell setFrame:myFrame];

        }
        else 
        {
            NSLog(@"You have swiped right");
            CGFloat movedDistance=currentPosition.x-gestureStartPoint.x;
            NSLog(@"The movedDistance is %f",movedDistance);
            if(movedDistance<=160)
            {
            myFrame.origin.x += deltaX;
                            backFrame.origin.x-=deltaX;
            }
            [cell setFrame:myFrame];
        }
        if ([swipeDelegate respondsToSelector:@selector(tableView:didSwipeCellAtIndexPath:)])
        {
            [swipeDelegate tableView:self didSwipeCellAtIndexPath:[self indexPathForRowAtPoint:gestureStartPoint]];
        }

        [self setIndexOfVisibleBackView:[self indexPathForCell:cell]];
    }

    [self setScrollEnabled:YES];

}
else
{
    [super touchesMoved:touches withEvent:event];
}
}


-(UIView *) addnewViewatPoint:(NSSet *)touches withEvent:event
 {

UIView *backgroundView=[[[UIView alloc] initWithFrame: CGRectMake(10.0, 30.0, 200.0, 25.0)] autorelease];
[backgroundView setBackgroundColor:[UIColor redColor]];
[backgroundView setUserInteractionEnabled:NO];
backgroundView.tag=101;
return backgroundView;
 }


 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
   {
if ([self supportsSwipingForCellAtPoint:gestureStartPoint])
{
    TISwipeableTableViewCell * cell = (TISwipeableTableViewCell *)[self cellForRowAtIndexPath:[self indexPathForRowAtPoint:gestureStartPoint]];
    if(isTouchesMoved==NO)
    {
        [self.delegate tableView:self didSelectRowAtIndexPath:[self indexPathForCell:cell]];
        [self touchesCancelled:touches withEvent:event];
    }

    [UIView beginAnimations:nil context:NULL];
    if(isTouchesMoved==YES)
    {
        [cell setFrame:prevLoc];
        [tempView setFrame:prevLocBack];
        isTouchesMoved=NO;
    }
    moved=TRUE;
    [UIView commitAnimations];
    [self touchesCancelled:touches withEvent:event];
    //[super touchesEnded:touches withEvent:event];
}
else
{
    [super touchesEnded:touches withEvent:event];
}

}

  • 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-20T15:43:23+00:00Added an answer on May 20, 2026 at 3:43 pm

    Could you not add the uiview that needs to be stationary to the view below the table?

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

Sidebar

Related Questions

So I have been working with Wordpress 3.x and trying to build a custom
I have been trying to build a user control with some custom properties set
I have been trying to build an online java compiler. But running the clients
I have been trying to learn how to build jQuery plugins, so I'm still
Have been trying to encrypt an xml file to a string so that I
I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
I am trying to build an application that converts my old custom Ethernet logs
I'm trying to get SBT to build a project that could have more than
I have been trying my hand at custom form builder methods in Rails. My
I have been trying to use some custom fonts within my WP7 app. I

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.