5

アプリで連絡先テーブル ビューを複製しようとしています。だから私はテーブルビューに表示された連絡先のリストを持っていますが、テーブルビューをアルファベットのすべての文字にセクション化し、連絡先の名前をファーストネームのリスター文字に関連するセクションに配置したいと思います. このような

ここに画像の説明を入力

どうすればそのビューを取得できますか? これまでのところ、これが私が行ったすべてです。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

        return [displayNames count];

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"ContactsCell";

    /*ContactCell *cell = (ContactCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];


    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ContactCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }*/
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }
     //   cell.name.text = [displayNames
       //                        objectAtIndex:indexPath.row];
    UILabel *namer = (UILabel *)[cell viewWithTag:101];
    namer.text=[displayNames
                    objectAtIndex:indexPath.row];
    /*
     Get the picture urls from the picture array and then 
     I loop through the array and initialize all the urls with 
     a NSUrl and place the loaded urls in anouther nsmutable array
     */
    urls = [[NSMutableArray alloc] init];

    for (id object in pictures) {
        //NSDictionary *names = res[@"image"];
        NSString *name = object;
        NSURL *url=[[NSURL alloc] initWithString:name];
        [urls addObject:url];
    }
   // cell.profile.image= [UIImage imageWithData:[NSData dataWithContentsOfURL: [urls objectAtIndex:indexPath.row]]];
    UIImageView *profiler = (UIImageView *)[cell viewWithTag:100];
    profiler.image= [UIImage imageWithData:[NSData dataWithContentsOfURL: [urls objectAtIndex:indexPath.row]]];


    return cell;
}
4

1 に答える 1