3

我想通过使用在 ios6 上打开地图,MKMapItem但我也想使用谷歌地图为旧 ios 版本回退......

我不知道在没有 BubbleWrap 的情况下在 ruby​​mtion 上执行此操作导致Device.ios_version返回错误

我想在 iOS6 上这样做:

address_dictionnary = ({kABPersonAddressStreetKey: @party.place.street, kABPersonAddressCityKey: @party.place.city,kABPersonAddressZIPKey: @party.place.postal_code})
place = MKPlacemark.alloc.initWithCoordinate(@coords, addressDictionary: address_dictionnary)
mapItem = MKMapItem.alloc.initWithPlacemark(place)
mapItem.name = "#{@party.name}"
options = ({
   MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
})
mapItem.openInMapsWithLaunchOptions(options)

这在旧版本上:

url = "http://maps.google.com/maps?saddr=#{@party.place.location[1]},#{@party.place.location[0]}&daddr=#{@party.place.location[1]},#{@party.place.location[0]}"
App::open_url(url)

谢谢你的帮助


然后当我做正确的测试时:当我做测试并在 IOS 5.1 上运行它时,我有这个错误

dyld: Symbol not found: _MKLaunchOptionsDirectionsModeDriving

这是我的代码:

if Utils.older_than_ios6?
  url = "http://maps.google.com/maps?saddr=#{@party.place.location[1]},#{@party.place.location[0]}&daddr=#{@party.place.location[1]},#{@party.place.location[0]}"
  App::open_url(url)
else
  address_dictionnary = ({kABPersonAddressStreetKey: @party.place.street, kABPersonAddressCityKey: @party.place.city,kABPersonAddressZIPKey: @party.place.postal_code})
  place = MKPlacemark.alloc.initWithCoordinate(@coords, addressDictionary: address_dictionnary)
  mapItem = MKMapItem.alloc.initWithPlacemark(place)
  mapItem.name = "#{@party.name}"
  options = ({
     MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
  })
  mapItem.openInMapsWithLaunchOptions(options)
end
4

1 回答 1

5

通过检查源代码Device.ios_version,您可以看到它返回UIDevice.currentDevice.systemVersion。所以这应该可以解决问题!

于 2012-10-05T13:49:26.337 回答