我想通过使用在 ios6 上打开地图,MKMapItem
但我也想使用谷歌地图为旧 ios 版本回退......
我不知道在没有 BubbleWrap 的情况下在 rubymtion 上执行此操作导致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