honcheng / PaperFold-for-iOS

Paper folding animation for iOS
Other
2.7k stars 399 forks source link

PaperFold an UITableViewCell #67

Open JeanetteMueller opened 11 years ago

JeanetteMueller commented 11 years ago

Hi, i want to use paperfold on a cell, but if i do so, i cant scroll the table. what's the best way to check draging and swiping?

my code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

NSString *cellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];

PaperFoldView *pv = [[PaperFoldView alloc] initWithFrame:CGRectMake(0, 0, 320, 90)];
[pv setEnableBottomFoldDragging:NO];
[pv setEnableTopFoldDragging:NO];
pv.delegate = self;

UIImageView *leftV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 90)];
leftV.image = [UIImage imageNamed:@"icon_directory_comedy.png"];
leftV.contentMode = UIViewContentModeCenter;
leftV.backgroundColor = [UIColor redColor];

UILabel *rightV = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 90)];
rightV.backgroundColor = [UIColor blueColor];
rightV.text = @"favourite";

[pv setLeftFoldContentView:leftV foldCount:1 pullFactor:0.9];
[pv setRightFoldContentView:rightV foldCount:1 pullFactor:0.9];

[pv setCenterContentView:cell.contentView];

//[cell.contentView removeFromSuperview];

[cell addSubview:pv];

[self configureCell:cell atIndexPath:indexPath];

return cell;
}
cooler333 commented 9 years ago

same problem

chewedon commented 9 years ago

Hello everyone, I hope this isn't too late but I came across this problem today and I found a fix.

It seems like the UIPanGestureRecognizer is stealing all the touches. We simply need to tell PaperFoldView to return YES in the recognize simulatenous gesture recognizer:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

You would of course need to set the delegate of the pan gesture variable to self on line 68 of PaperFoldView class:

UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onContentViewPanned:)];
panGestureRecognizer.delegate = self;

And don't forget to conform to the UIGestureRecognizerDelegate protocol in the PaperFoldView header file:

@interface PaperFoldView : UIView <MultiFoldViewDelegate, UIGestureRecognizerDelegate>

Hope that helps :D