开发者

buttontap on cell.image

开发者 https://www.devze.com 2023-03-09 14:47 出处:网络
well there is the - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)in开发者_Python百科dexPath

well there is the

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)in开发者_Python百科dexPath

but this is for the cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

How can i catch a clickevent on the cell.Image?


UIImage view does not decsend from UIControl that's why it does not have Touchepinside like target action method. So what I guess you can do is Create a UIButton object. Then set an image for it's normal state:

[imageButton setImage:[UIImage imageNamed:@"Icon.png"]
      forState:UIControlStateNormal];

Then set it's target action:

[imageButton addTarget:self action:@selector(buttonPushed:)
  forControlEvents:UIControlEventTouchUpInside];

And then :

[cell.contentView addSubview:imageButton];

I guess that'll do the job.

0

精彩评论

暂无评论...
验证码 换一张
取 消