Fixed screen orientation detection to be compatible with iOS6 on-screen keyboard