If your iPhone suddenly shuts off unexpectedly, the problem is most often due to a low battery. If your battery is fine, a problem with the software is likely the problem -- either the iOS software or an app. You can fix software problems yourself, so try resetting, updating or restoring the iPhone before assuming a physical problem with the hardware.

Easy Fixes

If your iPhone suddenly shuts off, connect it to a power supply. If the iPhone doesn't turn on automatically, wait 10 to 15 minutes and then turn it on. If the battery indicator is red, a dead battery likely caused the problem. If the iPhone has an adequate charge, resetting it will likely solve the problem. Hold down the Sleep/Wake button and the Home button at the same time for at least 10 seconds until the Apple logo appears on the screen.

Software and Hardware Problems

If the iPhone continues to shut down without any reason, your iOS software or an app you are using may be to blame, so it's important to update these. Restoring your iPhone to its factory settings can also solve a software problem. If neither of these solutions work, contact Apple or the place where you bought the iPhone. A problematic battery or a connection inside the device may be the culprit.

Overheating

The iPhone will shut itself off if it its temperature goes above 95 degrees. This can be a common problem if you leave your iPhone near a heat source, in direct sunlight, or if you leave it in a locked car. If overheating is the problem, the iPhone should display a "Temperature" warning. Don't attempt to use it again until it has cooled down.