En essayant de créer une application qui va ouvrir les cartes Apple situés dans le dispositif iOS avec une source donnée et l'adresse de destination.Ouvrir Apple Maps sur ios 8 et au-dessus ne fonctionne pas
NSString* addr = [NSString stringWithFormat: @"http://maps.apple.com/?daddr=%@&saddr=%@",[_fromTextfield.text stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]],[_toTextfield.text stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]];
addr=[addr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
NSURL* url = [NSURL URLWithString:addr];
if ([[UIApplication sharedApplication]canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
Mais canOpenURL ne fonctionne pas! Il renvoie toujours NO.
J'ai ajouté "LSApplicationQueriesSchemes urlscheme urlscheme2 urlscheme3 urlscheme4 " dans le fichier Info.plist.
canOpenURL: échec de l'URL: "http% 3A% 2F% 2Fmaps.apple.com% 2F% 3Fdaddr = Liverpool & saddr = Bath" - erreur: "URL d'entrée non valide" – user3182143
J'ai essayé votre code. – user3182143
Si ma réponse ci-dessous est utile pour vous, s'il vous plaît cocher et voter ma réponse. – user3182143