Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Don';t单击TableView中的内部按钮_Ios_Swift - Fatal编程技术网

Ios Don';t单击TableView中的内部按钮

Ios Don';t单击TableView中的内部按钮,ios,swift,Ios,Swift,我在表格视图中添加了一个按钮,但未单击该按钮。未单击表视图顶部的按钮。我应该怎么做才能使按钮可点击?我需要使CircleMenu按钮可点击。该按钮现在位于tableView3的顶部。是否需要将该按钮添加到表视图 override func viewDidLoad() { super.viewDidLoad() let button = CircleMenu( frame: CGRect(x: view.frame.w

我在
表格视图中添加了一个按钮,但未单击该按钮。未单击
表视图顶部的按钮。我应该怎么做才能使按钮可点击?我需要使CircleMenu按钮可点击。该按钮现在位于tableView3的顶部。是否需要将该按钮添加到
表视图

override func viewDidLoad() {
        super.viewDidLoad()
        let button = CircleMenu(
                        frame: CGRect(x: view.frame.width/2 - 10, y: view.frame.height - 270, width: 50, height: 50),
                        normalIcon:"icon_menu",
                        selectedIcon:"icon_close",
                        buttonsCount: 3,
                        duration: 4,
                        distance: 85)
                    button.backgroundColor = UIColor.flatSkyBlue
                    button.delegate = self
                    button.layer.cornerRadius = button.frame.size.width / 2.0
                  view.addSubview(button)

 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {


        if tableView == self.tableView1 {

        if !chipnumber2.text!.isEmpty {
            let cell:DeviceTableViewCell2 = tableView1.dequeueReusableCell(withIdentifier: cellIdNew, for: indexPath) as! DeviceTableViewCell2


            let deviceItem: Device3New = itemsNew[indexPath.row]

            let tap1 = UITapGestureRecognizer(target: self, action: #selector(tittleNewTapped(_:)))
            let tap2 = UITapGestureRecognizer(target: self, action: #selector(tittleNewTapped2(_:)))



                return cell
            }
        }

        if tableView == self.tableView2 {
            if !chipnumber.text!.isEmpty {
                let cell:DeviceTableViewCell2 = tableView2.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! DeviceTableViewCell2

                let deviceItem: Device3 = items[indexPath.row]



cell.backgroundColor = GradientColor(UIGradientStyle.leftToRight, frame: self.view.frame, colors: [UIColor.flatPowderBlueDark, UIColor.flatSand])
                return cell

            }

        }
        if tableView == self.tableView3 {
            if !chipnumber3.text!.isEmpty {
                let cell:DeviceTableViewCell2 = tableView3.dequeueReusableCell(withIdentifier: cellIdNew2, for: indexPath) as! DeviceTableViewCell2


                cell.backgroundColor = GradientColor(UIGradientStyle.leftToRight, frame: self.view.frame, colors: [UIColor.flatPowderBlueDark, UIColor.flatSand])
                return cell

            }

        }

        return UITableViewCell()

    }
}

只需将目标添加到按钮:

button.addTarget(self, action: #selector(buttonClicked(_:)), for: .touchUpInside)
然后是选择器方法:

@objc func buttonClicked(_ sender: UIButton) {
    print("clicked!")
}

(编辑:可能?

您应该添加委托方法