top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to get index path of UITableViewCell when we swipe cell

+1 vote
707 views

I am trying to get index path of cell when we make swipe.

I used below code to recognise cell swipe

in cellForRowAtIndexPath

UISwipeGestureRecognizer *cellRightSwipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self   action:@selector(cellRightSwipeGeture:)];
    [cellRightSwipe setDirection:UISwipeGestureRecognizerDirectionRight];
    [cell addGestureRecognizer:cellRightSwipe];

and action for RightSwipe

-(void)cellRightSwipeGeture:(UISwipeGestureRecognizer *)gestureRecognizer {
NSIndexPath *indexPath ;
UITableViewCell *cell = [_subItemTbl cellForRowAtIndexPath:indexPath];}

Here i can't identify that which cell was i swiped .

posted Jul 2, 2014 by Shiva

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

You Should use CGPoint to identify the touch position of swipe gesture.

-(void)swipeGesture:(UISwipeGestureRecognizer *)gestureRecognizer 
{
CGPoint location = [gestureRecognizer locationInView:yourTableName];
NSIndexPath *indexPath = [yourTableName indexPathForRowAtPoint:location]; 
NSLog(@"Index = %d",indexPath.row);
}
answer Jul 3, 2014 by Raju
Similar Questions
+1 vote

I want to check specified table contains value or its empty. I used number of complex method to find but no luck, any body can help me.

0 votes

I am developing my project which enables ARC feature but still some api am using is not having ARC featured code, So its throughs lot of error.

Here I need help from you to disable ARC for some class.

+1 vote

I used HTTP MANAGER REACHABILITY to check internet availability as provided by AFNetworking document http://cocoadocs.org/docsets/AFNetworking/2.2.4/index.html

NSURL *baseURL = [NSURL URLWithString:@"http://example.com/"];
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL];

NSOperationQueue *operationQueue = manager.operationQueue;
[manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
    switch (status) {
        case AFNetworkReachabilityStatusReachableViaWWAN:
        case AFNetworkReachabilityStatusReachableViaWiFi:
            [operationQueue setSuspended:NO];
            break;
        case AFNetworkReachabilityStatusNotReachable:
        default:
            [operationQueue setSuspended:YES];
            break;
    }
}];

but its not working.. i'm looking for your help.. Thanks

+1 vote

How to set image for UIImageView in UITableViewCell Asynchronously for each cell.

0 votes

how to use reusable identifier for table view cell in SWIFT.
In Objective C:

static NSString *identifier = @"mainMenuCell";
    cell =[tableView dequeueReusableCellWithIdentifier:identifier];  

Then how it should be in SWIFT

...