繁体   English   中英

为什么UITableViewCell采取长手势?

[英]Why is UITableViewCell taking long gesture?

我在UIView有一个UITableView ,我们称之为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文件可以在这里找到。

  2. View_A.m文件可以在这里找到。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM