为什么UITableViewCell采取长手势?

时间:2015-02-24 11:56:28

标签: ios objective-c iphone uitableview uiview

我在UITableView内有UIView,我们称之为view_A。有一个UIViewController,称之为mainViewController。里面有一个UIButton。在点击该按钮时,我将view_A作为子视图添加到mainViewController的视图中。 tableview中有几个菜单项。问题是tableview没有正确响应触摸。我必须长按细胞才能做出选择。它上面没有添加任何手势。没有其他观点可以涵盖它。这种行为绝对是古怪的。请查看以下代码并指出可能导致问题的原因。 这是mainViewcontroller中的委托实现/演示文稿:

 -(void) showDropDownMenu: (UIButton *) sender
    {
        UINib *nib = [UINib nibWithNibName:@"DropDownMenuView" bundle:nil];
        self.myView = [[nib instantiateWithOwner:self options:nil] objectAtIndex:0];
        self.myView.hidden = NO;
        self.myView.tag = 101;
        self.myView.delegate = self;
        self.myView.btnBack.hidden = YES;
        CATransition *transition = nil;
        transition = [CATransition animation];
        transition.duration = 0.2;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionPush;
        transition.subtype =kCATransitionFromBottom ;
        transition.delegate = self;
        [self.myView.layer addAnimation:transition forKey:nil];
        [self.view addSubview:self.myView];

    }

-(void) hideDropDownMenu
{
   CATransition *transition = nil;
    transition = [CATransition animation];
    transition.duration = 0.2;//kAnimationDuration
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
    transition.type = kCATransitionPush;
    transition.subtype =kCATransitionFromTop;
    transition.delegate = self;
    [self.myView.layer addAnimation:transition forKey:nil];
    self.myView.tag = 102;
    [UIView commitAnimations];



}
-(void) navigateBack
{

}
-(void) themeSelected: (NSIndexPath *) indexPath
{
    NSLog(@"%ld",(long)indexPath.item);
    themeNumber = [NSString stringWithFormat:@"%li",(indexPath.row+1)];
    [self setUpTheme];
}

这是cell.h文件的实现:

@interface ThemeTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *themeName;
@property (weak, nonatomic) IBOutlet UIImageView *themePreview;

这是cell.m文件的实现:

#import "ThemeTableViewCell.h"
@implementation ThemeTableViewCell
- (void)awakeFromNib {
    // Initialization code
    //ORIGINAL 82
    self.clipsToBounds = YES;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
  1. 我的View_A .h文件可以找到here

  2. 可以找到View_A.m文件here

  3. 更新:我记录了手势,并以某种方式将长按手势设置为单元格。

1 个答案:

答案 0 :(得分:0)

您是否禁用了cell imageview userInteraction,如果没有尝试此cell.yourImageView.userInteractionEnabled = NO