UIButton in Swift is not registering touches

后端 未结 18 882
情深已故
情深已故 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:17

    For those who are also stuck in the tutorial:

    I ran in to the same problem, when I was following Apple's "Start Developing iOS Apps (Swift)". It turned out that I had overlooked these code lines in the tutorial:

    override var intrinsicContentSize : CGSize {
        return CGSize(width: 240, height: 44)
    }
    

    Adding them to my RatingControl fixed the problem.

提交回复
热议问题