mapViewDidLoad and layerDidLoad

Discussion created by on Jan 24, 2014
Here is my issue. I'm trying to zoom to a certain envelop once a map has loaded. I first put the zoomToEnvelope in the mapViewDidLoad. However, sometimes the mapView spatial reference is still nil. I then decided to keep a count of the map layers and decrement my 'layer count'. Once the count is zero I try to zoomToEnvelope. Both these techniques work some of the time and will zoom into the center of the map other time. Does anyone have any idea as to why the spatial reference would not be set in the mapViewDidLoad or by the time the layerDidLoad?