gpt4 book ai didi

ios uiimagview 点击手势无法识别

转载 作者:行者123 更新时间:2023-12-01 20:08:36 31 4
gpt4 key购买 nike

表格 View 单元格内的 ImageView 点击手势不起作用。

以下是代码。

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath {


static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;

CGRect frame1 = CGRectMake(5, 0, 320, 30);
UILabel *label = [[UILabel alloc] initWithFrame:frame1];
label.text = @"READ THIS";
label.font = [UIFont fontWithName:@"Helvetica" size:15];
cell.backgroundColor = [UIColor colorWithRed:231.0f/255.0f green:234.0f/255.0f blue:235.0f/255.0f alpha:1.0];



UIImageView *downImage =[[UIImageView alloc] initWithFrame:CGRectMake(270,0,35,35)];
downImage.image=[UIImage imageNamed:@"downimg.png"];
downImage.userInteractionEnabled = YES;
downImage.tag = indexPath.row;

UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myFunction:)];
tapped.numberOfTapsRequired = 1;
[downImage addGestureRecognizer:tapped];

[label addSubview:downImage];
[cell.contentView addSubview:label];

最佳答案

请设置UserInteractionEnabledYES对于UILabel您要在其上添加 UIImageView作为 subview

房产 userInteractionEnabledUILabel 禁用默认情况下也是如此。

关于ios uiimagview 点击手势无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38158716/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com