Fixed iOS8 issues.

Ported Andrea Sprega iOS8 fixes.