UIButton in Swift is not registering touches

后端 未结 18 893
情深已故
情深已故 2020-12-29 21:11

I\'m trying to create a UIButton using Swift. It compiles fine and I can see my button in the simulator, but when I click it, nothing happens. This is the code I am using:

18条回答
  •  太阳男子
    2020-12-29 21:31

    I had the same issue when implementing UIButton and SearchBar on container view(UIView). In my case, the cause was the constraint issue. Constraint to searchBar had issue and because of this, function set had never been called.

    You can see if there's any from "Debug View Hierarchy" button. (constraint problem is shown as purple warning)

    (env: iOS12, xcode10.1)

提交回复
热议问题