当用户使用以下代码点击UITextField
中的UItableView
时,我试图处理一些操作,但未调用tapDetected:
代码。
UITableViewCell *cell = [[UITableViewCell alloc] init];
UITextField *txtComment=[[UITextField alloc]initWithFrame:CGRectMake(10, 10,cell.contentView.frame.size.width-30 , 30)];
[txtComment setText:NSLocalizedString(@"Comment Here", nil)];
[txtComment setFont:mediumFont];
[txtComment setTintColor:[UIColor grayColor]];
[txtComment setTag:newCommentTag];
txtComment.layer.masksToBounds=YES;
txtComment.layer.borderColor=[[UIColor lightGrayColor]CGColor];
txtComment.layer.borderWidth= 0.3f;
UITapGestureRecognizer *tap =
[[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(tapDetected:)];
tap.numberOfTapsRequired = 1;
[txtComment addGestureRecognizer:tap];
[cell.contentView addSubview:txtComment];
- (IBAction)tapDetected:(UIGestureRecognizer *)sender
{
[[NSNotificationCenter defaultCenter] postNotificationName:spAddNewCommentNotification object:nil];
}
最佳答案
您可以子类化您自己的UITableViewCell并将触摸检测放入其中。
关于ios - 在UITableView上点击手势未被调用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23508817/