Ios cell.imageView框架中的按钮

Ios cell.imageView框架中的按钮,ios,uitableview,Ios,Uitableview,如何在uitableViewcell中保留的imageview框架中放置信息按钮 提前谢谢 您只需创建按钮并将其添加到单元格中: UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; [infoButton setFrame:CGRectMake(10,10,infoButton.frame.size.width, infoButton.frame.size.height)]; [infoButton ad

如何在uitableViewcell中保留的imageview框架中放置信息按钮


提前谢谢

您只需创建按钮并将其添加到单元格中:

UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton setFrame:CGRectMake(10,10,infoButton.frame.size.width, infoButton.frame.size.height)];
[infoButton addTarget:self action:@selector(infoButtonTapped) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:infoButton];
编辑---

当您想要使用单元格的imageView属性时,需要提供自己的图像,并且需要设置手势识别器,以便知道何时点击了imageView

[cell.imageView setImage:[UIImage imageNamed:@"info-button.png"]];
[cell.imageView setUserInteractionEnabled:YES];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(infoImageTapped:)];
[tap setNumberOfTapsRequired:1];
[cell.imageView setGestureRecognizers:[NSArray arrayWithObject:tap]];
[tap release];

- (void) infoImageTapped:(UITapGestureRecognizer *) tap {
    //show info view.
}

您只需创建按钮并将其添加到单元格中:

UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton setFrame:CGRectMake(10,10,infoButton.frame.size.width, infoButton.frame.size.height)];
[infoButton addTarget:self action:@selector(infoButtonTapped) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:infoButton];
编辑---

当您想要使用单元格的imageView属性时,需要提供自己的图像,并且需要设置手势识别器,以便知道何时点击了imageView

[cell.imageView setImage:[UIImage imageNamed:@"info-button.png"]];
[cell.imageView setUserInteractionEnabled:YES];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(infoImageTapped:)];
[tap setNumberOfTapsRequired:1];
[cell.imageView setGestureRecognizers:[NSArray arrayWithObject:tap]];
[tap release];

- (void) infoImageTapped:(UITapGestureRecognizer *) tap {
    //show info view.
}

但我想在牢房的左边展示。如果我有一些文字,按钮会出现在文字上方。我想使用单元格的imageview属性。可能吗?谢谢谢谢这是非常有用的;)但我想在牢房的左边展示。如果我有一些文字,按钮会出现在文字上方。我想使用单元格的imageview属性。可能吗?谢谢谢谢这是非常有用的;)