如何在tableview中选择一个按钮? [英] How to select a button in the tableview?

查看:87
本文介绍了如何在tableview中选择一个按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用swift 3的tableview中的didSelectRowAt函数选择行。但是当我选择一行中的按钮时,如何执行其他操作?我不知道如何在tableview中选择一个按钮。

I can select row using the "didSelectRowAt" function in tableview of swift 3. But how do I do other actions when I select a button in a row? I do not know how to select a button in the tableview.

推荐答案

创建一个插座操作:使用此代码查找索引路径

Create an outlet action: And find the indexpath using this code

    @IBAction func memberPicTapped(_ sender:UIButton) {
            var superView = sender.superview
            while !(superView is UITableViewCell) {
                superView = superView?.superview
            }
            let cell = superView as! UITableViewCell
            if let indexpath = YourTableView.indexPath(for: cell){

            }
      }

这篇关于如何在tableview中选择一个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆