Apple - How does iPhone 5 get indoor altitude?
The iPhone does have two ways to get altitude, but the barometer is not one of them. You can only use a barometer for relative altitudes, not absolute, unless you know the current atmospheric pressure at sea level. But as well as GPS, Apple maintains a database of the locations (presumably including altitude) of a vast number of wifi networks, so if the wifi is enabled it can determine the altitude from the database. Try turning off wifi on your phone, and see if it can still get your altitude.