I am displaying Business card view on which I have one button on which I am setting Button title as phone number string which I got after parsing. I am getting perfect phone number string value on the button title. Now by pressing that button I want to call the default phone app so that User can call.
-(void) BcardDisp: (id)sender
{
BGView.hidden = NO;
if(BcardView.hidden == YES)
{
BcardView.hidden = NO;
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
marker *aMarker = (marker *)[appDelegate.markers objectAtIndex:selectedIndexPath.row];
for (int selectedIndexPath = 0; selectedIndexPath < [appDelegate.markers count]; selectedIndexPath++)
{
ShowroomName.text = aMarker.name;
Address_Bcard.numberOfLines=3;
Address_Bcard.text =aMarker.address;
[p_Bcard setTitle:[NSString stringWithFormat:@"%@",aMarker.phone] forState:UIControlStateNormal];
}
[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:YES];
}
}
For Calling number I am using following action on Button.
- (IBAction)callfrom_BcardVeiw
{
marker *aMarker = [[marker alloc] init];
NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"%d",aMarker.phone]];
[[UIApplication sharedApplication] openURL:phoneNumberURL];
NSLog(@"%d",phoneNumberURL);
}
But I am not able to call…..getting grabage value. What logic should I put under my – (IBAction)callfrom_BcardVeiw ….so that I can call on the same number as Button title string.
Try this: