Fix crash on iOS7

Ported #2520 to release/4.5