Thursday 15 September 2011

ios - Re-show rightBarButtonItem that relies on mapbox mapView? -



ios - Re-show rightBarButtonItem that relies on mapbox mapView? -

my application tab-based. on 1 tab map (which using mapbox for.) when click on tab, puts trackingbarbutton item on top right of navigationcontroller top bar. when clicked, button interacts mapview show user's location. issue having when go tab (besides map), need remove trackingbarbutton top right, not apply of other tabs.

here how mapview , tracking bar button initialized

- (void)viewdidload { [super viewdidload]; rmmbtilessource *offlinesource = [[rmmbtilessource alloc] initwithtilesetresource:@"example-map" oftype:@"mbtiles"]; rmmapview *mapview = [[rmmapview alloc] initwithframe:self.view.bounds andtilesource:offlinesource]; //initalize button in top-right self.tabbarcontroller.navigationitem.rightbarbuttonitem = [[rmusertrackingbarbuttonitem alloc] initwithmapview:mapview]; }

here hide button

- (void)viewwilldisappear:(bool)animated self.tabbarcontroller.navigationitem.rightbarbuttonitem = nil; }

now normally, re-initialize button in viewwillappear(), issue need utilize mapview object initialized in viewdidload(). have ideas on how can re-use object or hide rightbarbuttonitem rather deleting completely? prefer not re-initialized mapview each time.

thanks!

have tried modifying navigationitem of uiviewcontroller instead of uitabbarcontroller. way, rightbarbuttonitem should show when view controller shown , hide automatically when new uiviewcontroller shows own navigationitem. although i'm not 100% sure this.

- (void)viewdidload { ... //initalize button in top-right self.navigationitem.rightbarbuttonitem = [[rmusertrackingbarbuttonitem alloc] initwithmapview:mapview]; }

ios objective-c mapbox

No comments:

Post a Comment