我的tableview中的每个单元格都有一个按钮。我想在按下按钮时拨打一个号码。我用从代码之前调用是这样的:按下UITableViewCell中的按钮时无法启动呼叫
NSString *[email protected]"tel://";
NSString *cifra=customer.tel;
cifra1 = [cifra1 stringByAppendingString:cifra];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:cifra1]];
如果我的方法把这个代码“didSelectRowAtIndexPath方法”一切正常。但如果我把它放在-(IBAction)buttonPressed:(UIButton *) sender
什么都不会发生。我用NSLog检查了这个方法,它响应按钮点击。
出了什么问题?
编辑:奇怪,这个工程:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *[email protected]"tel://";
NSString *[email protected]"123456789";
cifra1 = [cifra1 stringByAppendingString:cifra];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:cifra1]];
}
和这并不,evethough客户数量正确读取:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Customer *c=[customerArray objectAtIndex:indexPath.row];
NSString *[email protected]"tel://";
NSString *cifra=c.tel;
cifra1 = [cifra1 stringByAppendingString:cifra];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:cifra1]];
}
你如何获得的电话号码,即'customer.tel'。这是不同的行不同?如果是的话,如何从'-buttonPressed:'方法中引用它。 – 2011-05-19 12:53:00
你可以显示完整的代码didSelectRowAtIndexPath为了我可以说什么是错误的(IBAction)buttonPressed:(UIButton *)发件人 – 2011-05-19 12:53:30
@Deepak:我记下从custoemr.tel号码时按下按钮,一切都很好,我得到正确的号码。 – DixieFlatline 2011-05-19 13:10:22