我有一个 UITableView,并且我将 phonenumber 作为 UITableViewCell 中的 UILabel 之一。当我单击该特定标签时,我应该能够拨打该特定号码。对于 UILabel 响应点击,我使用了 UITapGesture。但在检测要呼叫的号码我使用了 [sender tag],它会引发错误:“ [UITapGestureRecognizer tag]:无法识别的选择器已发送到实例”
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
lblphone = [[UILabel alloc] initWithFrame:CGRectZero];
lblphone.tag = 116;
lblphone.backgroundColor = [UIColor clearColor];
[lblphone setFont:[UIFont fontWithName:@"Helvetica" size:12]];
[lblphone setLineBreakMode:UILineBreakModeWordWrap];
[lblphone setUserInteractionEnabled:YES];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelButton:)];
[tapGestureRecognizer setNumberOfTapsRequired:1];
[lblphone addGestureRecognizer:tapGestureRecognizer];
[tapGestureRecognizer release];
[cell addSubview:lblphone];
}
CGSize constraint5 = CGSizeMake(320, 2000.0f);
CGSize size5=[phone sizeWithFont:[UIFont fontWithName:@"Helvetica" size:14] constrainedToSize:constraint5 lineBreakMode:UILineBreakModeWordWrap];
lblphone =(UILabel *)[cell viewWithTag:116];
[lblphone setFrame:CGRectMake(10,businessname.frame.size.height+businessname.frame.origin.y,320, size5.height)];
lblphone.textAlignment=UITextAlignmentLeft;
lblphone.backgroundColor=[UIColor clearColor];
lblphone.numberOfLines=0;
lblphone.lineBreakMode=NSLineBreakByClipping;
lblphone.font=[UIFont fontWithName:@"Helvetica" size:14];
lblphone.text=[NSString stringWithFormat:@"%@ ",phone ];
[lblphone sizeToFit];
}
-(IBAction)labelButton:(id)sender
{
selectedrowCall=[sender tag]; //error at this line
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://%@",[lblphone.text]]];//error at this line also :Expected Identifier
}
我如何才能呼叫仅在 tableviewcell 中单击的特定号码?我想确认我是否可以通过模拟器测试电话?