【发布时间】:2017-12-23 05:01:10
【问题描述】:
【问题讨论】:
-
嗨,你用共享扩展解决了这个问题吗
标签: objective-c iphone xcode maps sharing
【问题讨论】:
标签: objective-c iphone xcode maps sharing
Google Maps 和 Apple Plan 包含在 WhatsApp 操作表中,因为 WhatsApp 开发人员在他们的应用程序中实施了自定义操作表。如果不修改 WhatsApp 代码,您将无法出现在 WhatsApp 应用中
您需要在您的应用中执行自定义操作表
UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select
Sharing option:" delegate:self cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil otherButtonTitles:
@"Open in my custom app",
@"Open in Maps",
@"Open in Google maps",
nil];
popup.tag = 1;
[popup showInView:self.view];
然后你必须处理每个调用:
- (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (popup.tag) {
case 1: {
switch (buttonIndex) {
case 0:
//Your code to open in your app with your custom URL scheme
break;
case 1:
// Create an MKMapItem to pass to the Maps app
CLLocationCoordinate2D coordinate =
CLLocationCoordinate2DMake(16.775, -3.009);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:@"My Place"];
// Pass the map item to the Maps app
[mapItem openInMapsWithLaunchOptions:nil];
break;
case 2:
[someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]]
break;
default:
break;
}
break;
}
default:
break;
}
}
【讨论】: