如何通过XML分析器值从iPhone应用程序拨打电话? [英] How to make call from iphone app on xml parser value?
问题描述
我仍然无法使用先前的答案拨打电话.我正在解析xml文件以获取电话号码值(aMarker.phone =电话号码).其中标记是我在解析器控制器中获取的xml文件中的属性.我可以在Button标题上设置此电话号码字符串.但是,通过点击按钮,我无法拨打该号码.看看我的代码
I am still not able to make phone call using previous answer. I am parsing xml file to get phone number values (aMarker.phone= phone number). Where marker is attributes in xml file which I am fetching in my parser controller. I am able to set this phone number string on Button title. But by tapping button I am not able to call the number. See my code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(BGView.hidden == YES)
{
BGView.hidden = NO;
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
marker *aMarker = (marker *)[appDelegate.markers objectAtIndex:selectedIndexPath.row];
for (int selectedIndexPath = 0; selectedIndexPath < [appDelegate.markers count]; selectedIndexPath++)
{ [p_Bcard setTitle:[NSString stringWithFormat:@"%@",aMarker.phone]forState:UIControlStateNormal];
//getting correct number on p_Bcard button title.
}
}}
按钮操作代码:
-(IBAction)phonecallUpadated
{
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
marker *aMarker = (marker *)[appDelegate.markers objectAtIndex:selectedIndexPath.row];
for (int selectedIndexPath = 0; selectedIndexPath < [appDelegate.markers count]; selectedIndexPath++)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",aMarker.phone]]];
//not able to call pressing p_Bcard button using above action. method get call by setting breakpoint.
在这里我应该怎么做才能传递正确的字符串以拨打电话. }
What should I do here to pass proper string number to make phone call. }
推荐答案
首先将您的电话号码转换为UTF8编码字符串,然后创建NSURL.另一个明智的选择是在两个字之间(在两个电话号码之间)设置%20.
First of all convert your phone number to UTF8 encoding string then make NSURL. another wise set %20 between two words (between two phone no).
这篇关于如何通过XML分析器值从iPhone应用程序拨打电话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!