ios - 对 didselectrowatindexpath 的按钮操作

标签 ios swift user-interface

我在单元格中添加了一个容器 View 。但是当我尝试单击 View 中的按钮时,仅调用委托(delegate)方法 didselectrowatindexpath

enter image description here

如何处理didselectrowatindexpath之前的按钮点击?

最佳答案

给按钮添加目标方法如下图

cell.button.tag = indexPath.row;
[cell.button addTarget:self action:@selector(btnclick:) forControlEvents:UIControlEventTouchUpInside];

添加按钮点击方法如下

-(void)btnclick:(UIButton *)sender
{
    int index = sender.tag;

}

关于ios - 对 didselectrowatindexpath 的按钮操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34736756/

相关文章:

iphone - iOS — UITableViewCell reuseIdentifiers 是全局的吗?

iphone - 一个 View 中的两个或多个 Collection View

ios - Swift 在没有开关的情况下获取枚举中的关联值

ios - 向数据库添加信息 Parse.com 错误 PFObject

ios - 计算一些字符串 iOS 之前的字符

ios - 无法使用 'taskCreated' 类型的参数列表调用 '([String : String?])'

Swift版Facebook iOS SDK以及如何访问Response中的数据

xcode - Xcode-整个UI的深色主题

java - 如何在 JTable 行中设置自定义对象

python - 类型错误 : metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases