Sha256: 0b07fc28dfcca5832250e91d5886ce14ee6bfb1d53defe3f7d7e66c300ed5e3a
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
class BeerMapController < UIViewController def init if super self.tabBarItem = UITabBarItem.alloc.initWithTitle('Map', image:UIImage.imageNamed('map.png'), tag:1) end self end def loadView self.view = MKMapView.alloc.init view.delegate = self end def viewDidLoad view.frame = tabBarController.view.bounds # Center on Brussels. region = MKCoordinateRegionMake(CLLocationCoordinate2D.new(50.85, 4.35), MKCoordinateSpanMake(3.1, 3.1)) self.view.setRegion(region) Beer::All.each { |beer| self.view.addAnnotation(beer) } end def viewWillAppear(animated) navigationController.setNavigationBarHidden(true, animated:true) end ViewIdentifier = 'ViewIdentifier' def mapView(mapView, viewForAnnotation:beer) if view = mapView.dequeueReusableAnnotationViewWithIdentifier(ViewIdentifier) view.annotation = beer else view = MKPinAnnotationView.alloc.initWithAnnotation(beer, reuseIdentifier:ViewIdentifier) view.canShowCallout = true view.animatesDrop = true button = UIButton.buttonWithType(UIButtonTypeDetailDisclosure) button.addTarget(self, action: :'showDetails:', forControlEvents:UIControlEventTouchUpInside) view.rightCalloutAccessoryView = button end view end def showDetails(sender) if view.selectedAnnotations.size == 1 beer = view.selectedAnnotations[0] controller = UIApplication.sharedApplication.delegate.beer_details_controller navigationController.pushViewController(controller, animated:true) controller.showDetailsForBeer(beer) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubymotionr-0.0.1 | spec/multiple-rubymotion-apps/Beers/app/beer_map_controller.rb |