0
我有一個UITableView,並且我已將Uonable的電話號碼作爲UITableViewCell中的一個UILabel。當我單擊該特定標籤時,我應該可以撥打該特定號碼的號碼。對於UILabel響應點擊我把UITapGesture.But檢測哪個號碼被稱爲我使用的發送方標籤]其中引發錯誤:「[UITapGestureRecognizer標籤]:無法識別的選擇發送到實例」從應用程序調用電話號碼
- (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中點擊的那個特定號碼?我想確認我是否能夠從模擬器測試phonecalling?
This worked。謝謝你 – Sindhia
@辛迪亞歡迎您 – MCKapur