UIActivityViewController
画像やテキストを共有するのに最適な方法です。場所を共有するにはどうすればよいですか?画像とテキストを共有するために、対応するオブジェクトをに追加し、NSArray
それを。として渡しUIActivities
ます。を追加したいのですCLLocationCoordinate2D
が、これは構造体であり、オブジェクトではありません。
何か案は?
UIActivityViewController
画像やテキストを共有するのに最適な方法です。場所を共有するにはどうすればよいですか?画像とテキストを共有するために、対応するオブジェクトをに追加し、NSArray
それを。として渡しUIActivities
ます。を追加したいのですCLLocationCoordinate2D
が、これは構造体であり、オブジェクトではありません。
何か案は?
私は同じ問題を抱えていましたが、UIActivityViewController を介して座標を機能させるための答えが見つかりませんでした。
回避策として、WhatsApp で使用されているのと同様のアプローチを使用しました。ここでは、さまざまなマップ プロバイダーのアクション シートを取得します。次のコードは警告を表示し、Waze/Google マップ/Apple マップから特定の場所を開くことを選択できるようにします。インストールされているアプリのみが表示されます。「経度」と「緯度」の値を CLLocationCoordinate2D 緯度/経度プロパティに置き換えるだけです。
UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* appleMaps = [UIAlertAction actionWithTitle:@"Open in Maps" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.apple.com/?q=%@,%@", latitude, longitude]]];
}];
UIAlertAction* googleMaps = [UIAlertAction actionWithTitle:@"Open in Google Maps" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?q=%@,%@", latitude, longitude]]];
}];
UIAlertAction* waze = [UIAlertAction actionWithTitle:@"Open in Waze" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"waze://?ll=%@,%@", latitude, longitude]]];
}];
[alert addAction:appleMaps];
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]])
[alert addAction:googleMaps];
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"waze://"]])
[alert addAction:waze];
UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:nil];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];