Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You don't need to create outlets for each cell.</p> <p>Is your didSelectRowAtIndexPath method called?</p> <p>Then you could just do:</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *urlToOpen = @""; if( indexPath.section == 0 ){ // call number urlToOpen = @"tel:12125551212"; } else if( indexPath.section == 1 ){ // open website urlToOpen = @"http://www.google.nl"; } else { // open address NSString *destinationAddress = @"Amsterdam"; Class itemClass = [MKMapItem class]; if (itemClass &amp;&amp; [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) { CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:destinationAddress completionHandler:^(NSArray *placemarks, NSError *error) { if([placemarks count] &gt; 0) { MKPlacemark *placeMark = [[MKPlacemark alloc] initWithPlacemark:[placemarks objectAtIndex:0]]; MKMapItem *mapItem = [[MKMapItem alloc]initWithPlacemark:placeMark]; MKMapItem *mapItem2 = [MKMapItem mapItemForCurrentLocation]; NSArray *mapItems = @[mapItem, mapItem2]; NSDictionary *options = @{ MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving, MKLaunchOptionsMapTypeKey: [NSNumber numberWithInteger:MKMapTypeStandard], MKLaunchOptionsShowsTrafficKey:@YES }; [MKMapItem openMapsWithItems:mapItems launchOptions:options]; } else { //error nothing found } }]; return; } else { NSString *sourceAddress = [LocalizedCurrentLocation currentLocationStringForCurrentLanguage]; urlToOpen = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%@&amp;daddr=%@", [sourceAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [destinationAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; } } [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlToOpen]]; } </code></pre> <p>indexPath.section could also be indexPath.row, depending on how you made the tableView.</p> <p><strong>Edit:</strong> I have added the 'Get Directions' part. This checks if it is ios5 or ios6. </p> <p>For ios5 I use the LocalizedCurrentLocation from this post <a href="http://www.martip.net/blog/localized-current-location-string-for-iphone-apps" rel="nofollow">http://www.martip.net/blog/localized-current-location-string-for-iphone-apps</a></p> <p>For ios6 I use the CLGeocoder to get the placemark and then open the map with it and the current location.</p> <p>Remember to add CoreLocation.framework and MapKit.framework</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload