Going by user reports, the problem of iPhone screen turning black usually happens when iPhone is switched from Portrait to Landscape mode.
Some users have also reported the same problem while trying to open certain Apps and also after unlocking the device.
If your iPhone has not suffered from physical damage due to a drop, water damage, exposure to high temperature or other reasons, it is very likely that the problem of its screen going black is software related.
iPhone Screen Turning Black
It is possible that the screen of your iPhone is turning black due to a stuck program or process. You can rule out this possibility by restarting your device.
Shut down iPhone by going to Settings > General > Shut Down > use the Slider to Power OFF iPhone. After 30 seconds, restart iPhone by pressing the power button.
1. Force Restart iPhone
If the screen of your iPhone is still going black, try Force Restarting your device and it might help in fixing the problem.
iPhone 8 and later: Press and release Volume up button > press and release Volume down button > after this press and hold the Power button, until you see your device starting with Apple Logo.
iPhone 6s and below: Press and hold Power and Home buttons, until you see your device starting with Apple Logo.
iPhone 7, 7 Plus: Press and hold Power and Volume down buttons, until you see your iPhone starting with Apple Logo.
2. Free up Storage Space
Lack of storage space can prevent Apps from functioning properly and installing updates. Hence, make sure iPhone has sufficient remaining storage space.
1. Go to Settings > General > iPhone Storage.
2. On the next screen, you can see the amount of storage space used and remaining on your device.
If the remaining storage space on your device is less than 1.5 GB, you need to Free Up Storage Space.
3. Install Updates
Make sure that the latest version of iOS and Apps are installed on your device.
1. Go to Settings > General > Software Update.
2. On the next screen, wait for iPhone to check for Updates > Follow the prompts to install the update (If available).
4. Factory Reset iPhone
If above methods did not help, the problem might be due to damaged or corrupted software files. The solution in this case is to Erase All the Content (Data) & Settings from your device.
This can be achieved by Factory Resetting your device by following steps as provided in this guide: How to Factory Reset iPhone (3 Methods) .
5. Try DFU Mode Restore
If Factory Reset did not help, you can try DFU Mode Restore and see if this helps in fixing the problem.
The DFU Restore Process will erase both software and hardware settings on your iPhone and reinstall both operating system software and Firmware on your iPhone.