this is actually a problem with my cousins 5s and my 6s started doing it. With mine I've noticed it switch off just after I get the 20% battery warning a few times but always had charger with me so put it on charge. Today I was out without my phone charging case so couldn't put it on charge. I noticed mobile internet wasn't working so I restarted it pressing on off button and home button. Straight after it came back on it went off again. The battery said 50%. I tried turning it back on and it gave the flat battery sign with charger picture then came back on and straight back off. This happened 4 or 5 times always coming on and back off on second attempt. I left it off a few minutes and tried again this time it came back on and stayed on. I did lock the phone once it came back on (pressing on off button to blacken screen) don't know if that helped it stay on. Is there anything I can do to stop it going off when battery not flat. By the way the battery is now 35% and is staying on fine so it wasn't because of low battery or battery reading higher than it is why it went off.