Based on what you describe, it would not be trespassing because you went there with what was believed to be permission from a person who you might reasonably think could give you permission: a resident of the building. You then left when you learned you did not have permission. Entering space with what reasonably appears to be permission to do so is not trespassing.