When I put my hand over my iphones screen camera (on the front of the iphone) the screen goes all black. How can I fix it?

I don't know how to turn it off and on and it's realky annoying.

NOTHING IS WRONG WITH YOUR PHONE! IT IS OPERATING AS INTENDED!

All smartphones (both iPhones & Android phones) have an IR camera / sensor which is uses to detect if you phone is next to your face (as all humans, being warm-blooded, emit heat & the feint IR radiation that the IR sensor picks up when in close proximity) & turns off the screen so you don't accidentally push any buttons with your ears or face (accidentally hanging up). When you place your hand over the camera, it's also over that IR sensor (as it can't tell the difference between your hand & your face… Only that an IR source is near the screen), which cause the screen to turn off.

THE IR SENSOR Can't BE TURNED OFF AS IT IS CRITICAL FOR PROPER OPERATION OF YOUR PHONE (hence why I noted that it's operating as intended).

If you wish to cover up the camera without triggering the IR sensor, you'll want to use a glass-safe removable sticker to place over the camera. Just be aware that doing so may negatively impact some services (like FaceTime) while the sticker is in place, but that why it's recommended to use a removable sticker.

Hope this helps!

You mean the front facing camera. Actually what may be causing that is that you are placing you hand over the proximity sensor which is near the front facing camera.

Try restarting it, since that's not supposed to happen unless you are in a phone call, which is supposed to prevent accidental button presses.