我在UITableView的UITableViewCell中的UIViewController的视图中添加了UITapGestureRecognizer,为什么不触发?

| 标题很容易解释,但是我有一个UITableView,其中填充了自定义UITableViewCells。 在这些自定义UITableViewCells内部,我添加了显示自定义图像的自定义UIViewControllers。 在此UIViewController的UIView中,我添加了一个UITapGestureRecognizer,如下所示:
- (void)viewDidLoad {
[super viewDidLoad];

UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self 
                                                                             action:@selector(handleTap:)];
recognizer.numberOfTapsRequired = 1;
recognizer.delegate = self;
[self.imageView addGestureRecognizer:recognizer];

[recognizer release];
}

-(void)handleTap:(UITapGestureRecognizer *)sender{
NSLog(@\"Handling tap on ArticleTileViewController\");
}
当我运行该应用程序时,单元格会很好地填充图像,但是当我点击图像(或自定义UIViewController)时,什么也没发生!我的NSLog无法启动。我已经看了一个小时的代码,看不到我要去哪里了。 有人看到我想念的东西吗?还是他们以前遇到过这个?     
已邀请:
        如果您试图在每个单元格上获得一个按钮,请参阅此处的操作说明。看一看。 iPhone SDK:使用专用按钮而不是通过点击单元格来打开单元格     
        
UIImageView
对象的
userInteractionEnabled
默认设置为
NO
。这里也可能是这种情况。加
self.imageView.userInteractionEnabled = YES;
到您在问题中提出的
viewDidLoad
方法。     
        
- (void)viewDidLoad {
       UILongPressGestureRecognizer* gesture = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
       gesture.delegate = self;
       [myWebView addGestureRecognizer:gesture];
}

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

要回复问题请先登录注册