There are numerous reports of the camera in iOS 4 failing to open. I've seen it quite a bit on my iPhone 4, but it comes and goes. While some folks are swapping out hardware, I'm not so sure this is a hardware issue. I still advise you to call Apple or visit a Genius Bar, but this appears to be a memory issue more than anything. I'm hoping iOS 4.1 will fix the problem.
What happens is that you go to use the camera on your phone, and the shutter won't open. You may see this in the Camera app, or in other apps like Facebook or Ya Gotta See This! which use the iPhone's camera. In other apps it may simply be that you can't click the button to take a pic, or the image of what you'd see never appears. Either way, something is gumming up the works. Here are a few possible fixes:
1. If you're multitasking and you have a bunch of apps that use a lot of memory (games, usually) open when you double-click the home button, you may want to force some of those to close. Just hold down an icon for a couple of seconds as those you were going to move icons around, and you'll see a red circle with a white minus sign. Tap as many apps as you can live without for the moment, close out the shelf, and go back to the camera. If memory has cleared up, you may get a picture.
2. One way to clear the memory is to reboot the iPhone. Just hold down the power button until the red slider appears to power down the device. Turn it back on and see if you can take a picture.
More on the next page.
[Hat tip to Brandon Martinez]