2015-07-11 60 views
-2
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
    return contactName.count; 
} 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 

if (cell == nil) 
{ 
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"]; 

} cell.textLabel.text = [contactName objectAtIndex:indexPath.row]; 
NSDictionary *number = [mobileNo objectAtIndex:indexPath.row]; 
cell.detailTextLabel.text = [number valueForKey:@"mobile"]; 
return cell; 
} 

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ 
    if (editingStyle == UITableViewCellEditingStyleInsert) { 
     NSLog(@"Wait"); 
    } 
} 
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 

UITableViewCell *tablecell1=[tableView cellForRowAtIndexPath:indexPath]; 

BOOL isselected=(tablecell1.accessoryType==UITableViewCellAccessoryCheckmark); 
if (isselected) { 
    tablecell1.accessoryType=UITableViewCellAccessoryNone; 
}else 
{ 
    tablecell1.accessoryType=UITableViewCellAccessoryCheckmark; 
} 


    } 

//done button action performs copy the contacts from phone to uitextview . 
- (IBAction)done:(id)sender 
{ 

} 

回答

-1
NSArray *indexSelected = [yourtableview indexPathsForSelectedRows]; 
NSMutableString *strPhoneNumbers = [NSMutableString stringWithFormat:@""]; 
    for (NSIndexPath *index in indexSelected) { 

     NSString *name = [contactName objectAtIndex: index.row]; 
     NSDictionary *number = [mobileNo objectAtIndex:index.row]; 
     NSString *number = [number valueForKey:@"mobile"]; 
     NSString *contactInfo = [name stringByAppendingString: number]; 
     [strPhoneNumbers appendString:[contactInfo stringByAppendingString:@"\n"]]; 

    } 
    youtextView.text = strPhoneNumbers; 

尝试用这种希望它能对你有用

相关问题