If you can briefly get the screen to respond, try these steps to prevent the issue from returning:
: Unplug any Lightning accessories or chargers, as faulty third-party cables can cause electrical interference with the digitizer. 3. Advanced Software Fixes How Do I Fix An Unresponsive Iphone 12 Screen
: If you experience "ghost touches" (the screen moving by itself), go to Settings > Accessibility > Touch > Touch Accommodations and enable Ignore Repeat . If you can briefly get the screen to
: Use a soft, lint-free microfiber cloth to remove dirt, oil, or water. lint-free microfiber cloth to remove dirt
: Take off your phone case and remove any screen protector, as these can sometimes put uneven pressure on the display or trap debris that causes "ghost touches".