Из закодированного подробного вида моего приложения, в котором есть сгруппированное табличное представлениеЯ хочу, чтобы приложение набирало выбранный номер телефона или отправляло текст или отправляло электронную почту, если щелкнуть по электронной почте, и переходить на карты Google, если адрес выбран.это мой didSelectRowAtIndexPath .. и он не работает.Я не знаю, как получить информацию о выбранной ячейке.Пожалуйста, помогите.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Directory *text = (Directory *)[tableView cellForRowAtIndexPath:indexPath];
//check content of text.
NSLog(@"Phone Number Selected is %@", text);
//NSString *dialHome = [dispHomephone stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:17148581499"]]
}
А вот мой cellForRowAtIndexPath, если это поможет.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
int cellPhoneLen = [dispCellphone length];
int workPhoneLen = [dispWorkphone length];
int homePhoneLen = [dispHomephone length];
int emailLen = [dispEMail length];
NSString *address = [NSString stringWithFormat:@"%@\n"@"%@ %@ %@\n"@"%@", dispAddress, dispCity, dispState, dispZip, dispCountry];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
// Configure the cell...
switch (indexPath.section)
{
case 1:
{
if (homePhoneLen != 0)
{
switch (indexPath.row)
{
case 0:
{
if (homePhoneLen != 0)
{
cell.textLabel.text = NSLocalizedString(@"home :", @"homephone label");
cell.detailTextLabel.text = dispHomephone;
} break;
case 1:
if (workPhoneLen != 0)
{
cell.textLabel.text = NSLocalizedString(@"work :", @"workphone label");
cell.detailTextLabel.text = dispWorkphone;
} break;
case 2:
if (cellPhoneLen != 0)
{
cell.textLabel.text = NSLocalizedString(@"mobile :", @"cellphone label");
cell.detailTextLabel.text = dispCellphone;
}
}
}
}
else if (workPhoneLen != 0)
{
switch (indexPath.row)
{
case 0:
{
if (workPhoneLen != 0)
{
cell.textLabel.text = NSLocalizedString(@"work :", @"workphone label");
cell.detailTextLabel.text = dispWorkphone;
} break;
case 1:
if (cellPhoneLen != 0)
{
cell.textLabel.text = NSLocalizedString(@"mobile :", @"cellphone label");
cell.detailTextLabel.text = dispCellphone;
}
}
}
}
else if (cellPhoneLen != 0)
{
cell.textLabel.text = NSLocalizedString(@"mobile :", @"cellphone label");
cell.detailTextLabel.text = dispCellphone;
}
} break;
case 2:
{
if (emailLen != 0)
{
cell.detailTextLabel.text = dispEMail;
}
} break;
case 3:
{
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.numberOfLines = 3;
cell.detailTextLabel.text = address;
} break;
}
return cell;
}