Search code examples
iosuikitios-simulator

why can't I tap uibutton in simulator but I can on my hardware iPhone?


I have two buttons on the top of my view controller, which is modally presented. The strange thing is that the buttons are not at all selectable when I click on them in the simulator. The buttons cause no issues when I use them on my iPhone.

btn.addTarget(self, action: #selector(sendTapped), for: .touchUpInside)

That's the way I add my function to the button

Whole button code:

let post: UIButton = {
        let btn = UIButton()

        btn.frame = CGRect(x: 0, y: 0, width: 60, height: 30)
        btn.setTitleColor(UIColor.lightGray.adjust(by: 20), for: .normal)
        btn.isEnabled = false
        btn.setTitle("Post", for: .normal)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 20, weight: .bold)
        btn.addTarget(self, action: #selector(sendTapped), for: .touchUpInside)

        return btn
    }()

enter image description here


Solution

  • Looks like what I had to do was change the iPhone to an X from an 8 in the simulator to solve my problem.