2017-07-18 70 views

回答

0

你需要做一個自定義的動作片在你的應用程序

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; 
    } 
} 
+0

@PeterSmith你聽錯了,我需要的是溝通與我的應用程序的鏈接,就像如果你從WhatsApp共享位置給它你在谷歌地圖或蘋果地圖上打開兩個選項我需要一種方式來彈出我的應用程序名稱,以便鏈接可以交流也可以通過我的應用程序來解決。 –

+0

它在WhatsApp中這樣做,因爲他們在他們的應用中實現了自定義操作表,正如我所描述的。您將無法在不修改WhatsApp代碼的情況下出現在WhatsApp應用程序中。 –