mapbox / DEPRECATED-mapbox-ios-sdk

REPLACED – use https://www.mapbox.com/ios-sdk instead
https://github.com/mapbox/mapbox-gl-native
Other
323 stars 8 forks source link

RMMapView via Interface Builder #454

Closed hasanadil closed 10 years ago

hasanadil commented 10 years ago

Hi, Its cumbersome to create an instance of RMMapView via the Interface Builder. This is because when its constructed from the nib via the initWithFrame, the map gets the default "exampe" map. I then have to switch the map once its loaded and its looks weird as the maps get swapped in front of the user.

Could the default initializer not set any underlying map layer. It's documented behavior but makes it difficult to use via IB. Works perfect fine when I just create it in code via initWithFrame: andTilesource:

Thanks.

incanus commented 10 years ago

That's an interesting idea. Related: I've been meaning to look into the new IBDesignable stuff in iOS 8, which should make NIB-based config a lot more flexible.

As a short-term workaround, could you subclass RMMapView (much as RMStaticMapView has) and make a new default initializer?

hasanadil commented 10 years ago

Good idea, will do.

The IBDesignable would expose an object's property within the IB inspector. But may not help with providing a default initializer that is not initWithFrame. Could make the RMMapboxSource property available in IB, but thats a complex object. Maybe have a property called mapId which of type nsstring, and make that IBDesignable, setting that properly manually or in IB, would create the RMMapboxSource object and assign it to the map view.

But it may still flickr, because the map will load with the example map, then get preempted and load the user's map.

incanus commented 10 years ago

I should point out here for your debugging purposes that IB doesn't actually call -initWithFrame:, but rather -initWithCoder:. You will then see a comment in -layoutSubviews pertaining to the initial tile source setup in those instances which has some background.

hasanadil commented 10 years ago

Hi justin,

Thanks, I made a typo in writing the comment above, sorry about the confusion. I ran into some other issues when wiring it via IB, so have it in code.

incanus commented 10 years ago

Could make the RMMapboxSource property available in IB, but thats a complex object. Maybe have a property called mapId which of type nsstring, and make that IBDesignable, setting that properly manually or in IB, would create the RMMapboxSource object and assign it to the map view.

I see what you mean here now, given that:

You can attach the IBInspectable attribute to any property in a class declaration, class extension, or category for any type that’s supported by Interface Builder’s defined runtime attributes: boolean, integer or floating point number, string, localized string, rectangle, point, size, color, range, and nil.

https://developer.apple.com/library/prerelease/ios/recipes/xcode_help-IB_objects_media/CreatingaLiveViewofaCustomObject.html

So I may not worry about this for now -- I'm not sure it's worth auto-adding a tile source just for IB.