[XCODE] Map application with links to websites

Socius Decennalis
Decennium
Joined
Aug 15, 2008
Messages
489
Reaction score
43
Hello,

I have been creating an iPhone application that has a map with annotations/pins on different places. Clicking on the annotation/pin will bring up some information about the place and below it should be a link to the website.

I watched a tutorial about how to create these annotations/pins and I managed to create them just fine. However, I am not able to find a way to create a link in the subtitle of the pin.

Code:
    myAnn = [[Annotation alloc] init];
    location.latitude = COMPANY_LATITUDE;
    location.longitude = COMPANY_LONGTITUDE;
    myAnn.coordinate = location;
    myAnn.title = @"Company OY";
    myAnn.subtitle = @"http://www.companywebsite.com/";
    [locations addObject:myAnn];

How can I make it so that the myAnn.subtitle would be a link that opens in web browser instead of just a text?
 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.companywebsite.com"]];
 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.companywebsite.com"]];
That code just instantly opens up the website, doesn't it?
What I need is to make the myAnn.subtitle be a link and once it is pressed will open up the website.

Basically, I don't know how to make the myAnn.subtitle to be clickable so it would run that code.
Can I even make NSString clickable?

EDIT: Nevermind! Solved the problem. Had to create a UIButton to the annotation and make it clickable.
 
Last edited:
Back