我想将此pan识别器添加到整个屏幕,它应该在特定区域。
- (void)panDetected:(UIPanGestureRecognizer *)panRecognizer
{
CGPoint translation = [panRecognizer translationInView:self.documentImageView];
CGPoint imageViewPosition = self.documentImageView.center;
imageViewPosition.x += translation.x;
imageViewPosition.y += translation.y;
self.documentImageView.center = imageViewPosition;
[panRecognizer setTranslation:CGPointZero inView:self.view];
}
这个pan识别器可以放在顶部的self.tableView.tableHeaderView.frame吗?
- (void)setExtractedImageForTableView:(UIImage *)extractedImage
{
self.documentImageView.image = nil;
self.documentImageView = nil;
self.documentImageView = [[UIImageView alloc] initWithImage:extractedImage];
self.documentImageView.userInteractionEnabled = YES;
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];
[self.documentImageView addGestureRecognizer:panRecognizer];
self.documentImageView.contentMode = UIViewContentModeScaleAspectFit;
if (!CGSizeEqualToSize(extractedImage.size, CGSizeZero)) {
self.documentImageView.frame = CGRectMake(CGRectGetMinX(self.view.frame), CGRectGetMinY(self.tableView.frame), CGRectGetWidth(self.view.frame), (extractedImage.size.height/extractedImage.size.width) * CGRectGetWidth(self.view.frame));
self.tableView.tableHeaderView = self.documentImageView;
[self.tableView setContentOffset:CGPointZero animated:YES];
CGRect frame = self.documentImageView.frame;
frame.size.height = self.documentImageView.frame.size.height + 100;
self.tableView.frame = CGRectMake(0, 0, 200, 200);
self.tableView.tableHeaderView.frame = frame;
}
}
答案 0 :(得分:0)
在UITableView标题中添加UIView查看,然后在该视图中添加手势。