UIButton is working on Simulator but not on Device

I have a variety of button which include a bunch of views and work absolutely fine with any simulator device. However, the moment I download the app on a physical device the same button doesn't react. Has this ever happened to anyone?

I used iOS 15.3.1 on my physical device (iPhone 12 Pro).

Answered by nicolaischneider in 817832022

Very late to the answer but the solution was to simply add a UITapGestureRecognizer:

let tapGesture = UITapGestureRecognizer(target: self, action: action)
button.addGestureRecognizer(tapGesture)

Which simulator (iPhone 12 Pro also ?).

Could you show how exactly you defined the button (which type). In storyboard or in code ?

And show the IBAction as well ?

Same issue ,Any solution for this problem,,

Accepted Answer

Very late to the answer but the solution was to simply add a UITapGestureRecognizer:

let tapGesture = UITapGestureRecognizer(target: self, action: action)
button.addGestureRecognizer(tapGesture)
UIButton is working on Simulator but not on Device
 
 
Q