Why does my iPhone 5 keep locking itself?

My iPhone 5 has recently been locking itself whenever I'm using it. Sometimes the "Slide to Power Off" screen will appear out of no where. Whenever I turn off the phone it just turns itself back on. This is the only problem I've had with it.

This actually happened to me with my 5s. Most likely the on/off button on the top is stuck. Have you noticed it doesn't come up all the way or its hard to press down? If so, take it to an apple store and explain the situation, they usually get it fixed in half an hour to an hour.

Sell it its gonna give you more problem after

Yeah its stuck just go to apple

The sleep/power button is sticking. You can either clean it or take it to an Apple store to be cleaned.

  • Why is my iPhone locking and trying to turn off by its self? My iPhone has been trying to turn itself off and locking the screen for ages, at first i thought that it would go away but it hasn't, it also turns itself back on if i turn it off does anyone know how to make it stop?
  • Why does my iphone screen keep controlling itself? So my iphone is in horrible shape, in terms of a broken screen. It's having a hard time responding to touch and I can't type. Also, it keeps opening apps on its own. Someone told me that the screen is pressing up against the digitizer and is acting as if I was touching the screen due to the cracks. If so, can I just replace the broken screen or do I have to buy another phone? I want to wait on the iphone 6 to use my upgrade.
  • Why does my iphone 8 keep locking me out? I'm the only one who knows the knows the passcode, and i'm not dumb when it comes to downloading apps i can restart the phone twice so it fixes and i can get back in, but after that i'm locked out until my phone gets disabled like really apple i'm not buying your 1200 dollar phone
  • Why does my iphone 4s keep turning itself off and on? My Iphone 4s(Jaill broken) wasn't showing the home screen wall paper so i thought it was one of the Cydia tweaks so i started deleting some of them made my iphone stuck, so i desided to turn it off and when i did it keeps turning it self on and off on and off… And i won't connect with my Computer and i'm not in America atm so there's no Apple store around can some one please help me?