Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 90

AussieRyan
Aspiring developer
Profile
Posts: 148
Reg: Mar 21, 2012
Margate, QLD Au...
1,480
07/20/16 02:25 PM (8 years ago)

change phone number string to clickable link

As a non-coder, I have not found a solution I can understand. I have a line of code that uses phone from JSON data: [[self phone] setText:[NSString stringWithFormat:@"Phone: %@",[placeDetails objectForKey:@"phone"]]]; How can I change this to add telprompt? so I can click the link to make a phone call and return when call is finished?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/20/16 05:31 PM (8 years ago)
If you're displaying an HTML page, you can embed a link in HTML that will work for both android and iOS... <a href="tel:555-555-5555">Call Us at 555-5555</a> alternatively, you can code for the platform. iOS: -(void)callPhone { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:5555555555"]]; } Not sure about Android; I've mostly used HTML links for that. Cheers! -- Smug
 
AussieRyan
Aspiring developer
Profile
Posts: 148
Reg: Mar 21, 2012
Margate, QLD Au...
1,480
like
07/23/16 06:51 PM (8 years ago)
My code above places some text Phone: with a value extracted from the JSON data - phone, onto a xib file. I am not sure how to implement your solution
 
AussieRyan
Aspiring developer
Profile
Posts: 148
Reg: Mar 21, 2012
Margate, QLD Au...
1,480
like
07/23/16 07:02 PM (8 years ago)
The complete code segment is: -(void)viewWillAppear:(BOOL)animated { [[self description] setText:[placeDetails objectForKey:@"description"]]; [[self name] setText:[placeDetails objectForKey:@"name"]]; [[self street] setText:[placeDetails objectForKey:@"street"]]; [[self city] setText:[NSString stringWithFormat:@"%@, %@",[placeDetails objectForKey:@"city"],[placeDetails objectForKey:@"state"]]]; [[self phone] setText:[NSString stringWithFormat:@"Phone: %@",[placeDetails objectForKey:@"phone"]]]; [[self description] setText:[placeDetails objectForKey:@"description"]]; [[self description] setNeedsDisplay]; if([(NSString *)[placeDetails objectForKey:@"pics"] length]==0) { self.picsAvailable.hidden=YES; } else { self.picsAvailable.hidden=NO; } if([(NSString *)[placeDetails objectForKey:@"youtube"] length]==0) { self.youTubeVideoAvailable.hidden=YES; } else { self.youTubeVideoAvailable.hidden=NO; }
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.