小编r_s*_*rma的帖子

按钮操作在子视图上不起作用

在我的一个 iOS 项目中,我以编程方式在我的 Feed ViewController(主视图)上添加了 Filter ViewController(子视图)的子视图。

Filter ViewController 上有几个按钮可以选择价格、城市等。

插座已连接,但当我尝试拍摄按钮动作时,它不起作用。我还启用了 isUserInteractionEnabled 但它仍然不起作用。

附件。对我来说,这与视图上的子视图有关!但要解决这个问题。你能建议我如何拍摄子视图发生的按钮动作吗?

class FilterViewController: BaseUIViewController{

   override func viewWillAppear(_ animated: Bool) {
     super.viewWillAppear(animated)

     cityButton.isUserInteractionEnabled = true
   }

   @IBAction func selectCity(_ sender: Any)
   {
    print("selectCity action")
   }
}
Run Code Online (Sandbox Code Playgroud)

filtering button subview ios swift

0
推荐指数
1
解决办法
2594
查看次数

标签 统计

button ×1

filtering ×1

ios ×1

subview ×1

swift ×1