2014-02-17 115 views
-3

我创造的一些记录数组,并希望进行电话设施选择任何cell..like 8904490035打电话给

-(void)viewDidLoad { 
    arryAppleProducts = [[NSArray alloc] initWithObjects:@"8904490035",@"iPod",@"MacBook",@"MacBook Pro",nil]; 
    arryAdobeSoftwares = [[NSArray alloc] initWithObjects:@"Flex",@"AIR",@"Flash",@"Photoshop",nil]; 
    arryAdobeSoftwares1 = [[NSArray alloc] initWithObjects:@"one",@"two",@"three",@"four",nil]; 
    self.title = @"Simple Table Exmaple"; 

    [super viewDidLoad]; 
} 

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    NextViewController *nextController = [[NextViewController alloc] initWithNibName:@"NextView" bundle:nil]; 
    [self.navigationController pushViewController:nextController animated:YES]; 

    if(indexPath.section == 0) 
     [nextController changeProductText:[arryAppleProducts objectAtIndex:indexPath.row]]; 
    else if(indexPath.section==1) 
     [nextController changeProductText:[arryAdobeSoftwares objectAtIndex:indexPath.row]]; 
    else 
     [nextController changeProductText:[arryAdobeSoftwares1 objectAtIndex:indexPath.row]]; 
} 
+1

不清楚你在问什么 –

+1

你想要做什么didSelectRowAtIndexPath –

+0

对于电话呼叫使用[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@“tel:42342334234”]]; – cjd

回答

1

1)时,对于来自arryAppleProducts我们下面调用动态对象:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",[arryAppleProductsobjectAtIndex:indexPath.row]]]]; 

2)调用特定的一个没有arryAppleProducts的第一目的使用以下:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",[arryAppleProducts objectAtIndex:0]]]]; 

通过更换0作为每个阵列

3)的对象的你的需要数目对于主叫特定数目使用以下:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:8904490035"]]]; 
+0

Frndu请格式答案。 –

0

添加一个方法这样&然后从tableViewDidSelectRowAtIndexPath

-(void)callOnMobile:(NSString *)phone { 
self.phoneNumber = phone; 
if(phone.length) { 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", self.phoneNumber]]]; 
}else { 
     UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Phone Call" 
                message:@"Number Invalid" 
                delegate:self 
             cancelButtonTitle:@"Dismiss" 
             otherButtonTitles:nil, nil]; 
     [alert show]; 
    } 
} 


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
NextViewController *nextController = [[NextViewController alloc] initWithNibName:@"NextView" bundle:nil]; 
[self.navigationController pushViewController:nextController animated:YES]; 

if(indexPath.section == 0) 
    [nextController changeProductText:[arryAppleProducts objectAtIndex:indexPath.row]]; 
    [self callOnMobile:[arryAppleProducts objectAtIndex:indexPath.row]]; 
    ... 
    ... 
else if(indexPath.section==1) 
    [nextController changeProductText:[arryAdobeSoftwares objectAtIndex:indexPath.row]]; 
else 
    [nextController changeProductText:[arryAdobeSoftwares1 objectAtIndex:indexPath.row]]; 
} 
调用它

这将解决你的目的。