How to fix my iPhone camera?

Recently my camera on my iphone 4 has been messing up. I know I didn't do anything to it because I just used it the other morning and it was perfectly fine. A lot of times the shutter won't open and when it does its just a black screen. Also, when I try to turn it to the front camera it just freezes and then shuts off. I've tried turning it off and back on. If anyone has any idea on how to fix it please let me know.

Turn your device off and on again by pressing and holding the Sleep/Wake button for a few seconds.
Try resetting all settings on your iPhone: Settings > General > Reset. Note that this will reset all of your preferences and settings but this will not affect all your data and media
Better still try a reset.