【问题标题】:How to display the selected phone contacts in uitextview in my app ..?如何在我的应用程序的 uitextview 中显示选定的电话联系人..?
【发布时间】:2015-07-11 10:53:01
【问题描述】:
-(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
{

}

【问题讨论】:

    标签: ios objective-c iphone uitableview


    【解决方案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;
    

    试试这个希望对你有用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-24
      • 1970-01-01
      • 2019-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      相关资源
      最近更新 更多