There are many reasons why this could be going on with your iPhone, and several ways to cure that behavior of your iPhone. But until you give more details about your iPhone, the application, condition of the iOS and so on, i think no one can magically tell you how to fix that except suggesting you to factory restore your iPhone. So take your time and give out the more possible details which might help others to figure out what is the trouble with your iPhone and be able to help you fix it.