2011-07-25 10 views
0

現在、私はグループ化されたオプションでUITableViewControllerを持っています。私はそれに隣接するプロフィールの連絡先の写真とその名前を持つアドレス帳のUIに似た何かを作成しようとしています。 会社名の上にプロフィール画像を追加する方法はありますか?すべての例またはApple Book Referenceが参考になります。iphoneでUITableViewGroupedの連絡先プロフィール画像を作成する方法

enter image description here

答えて

0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

// Create 
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    //cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 

} 

// Configure 
switch (indexPath.row) { 
    case 0: 
     cell.textLabel.text = @"    Evolutions"; 
     cell.backgroundColor=[UIColor clearColor]; 
     cell.textLabel.textColor=[UIColor whiteColor]; 
     CGRect myImageRect =CGRectMake(20,10,75,80); 
     UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect]; 
     [imageView setImage:[UIImage imageNamed:@"page-1.jpg"]]; 
     [cell addSubview :imageView]; 
     [imageView release]; 

     UIButton *btnView= [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
     [btnView addTarget:self action:@selector(View:)forControlEvents:UIControlEventTouchDown]; 
     [btnView setTitle:@"View" forState:UIControlStateNormal]; 
     [btnView setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
     btnView.frame=CGRectMake(235,36, 72,30); 

     [ cell addSubview: btnView]; 
     break; 

enter image description here

私はuがこのコードを使用し、この画像のようにアドレス帳を作成する必要があります。

0

名前と連絡先の画像を取得するためのコードは、セルとして

+ (NSMutableArray *) getAllContacts { 

    // Fetch the address book 
    ABAddressBookRef addressBook = ABAddressBookCreate(); 
    NSArray *people = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); 
    NSMutableArray *contacts = [NSMutableArray array]; 

    for (CFIndex i = 0; i < [people count]; i++) { 

    ABRecordRef record = [[people objectAtIndex:i] retain]; 
    NSString *fullname =(NSString *)ABRecordCopyCompositeName(record); 
    NSMutableDictionary *dict = [NSMutableDictionary dictionary] ; 
    if (![contacts containsObject:fullname]) { 
     [dict setValue:fullname forKey:@"name"]; 
     changes = YES; 
    } 
    if (ABPersonHasImageData(record)) { 
     UIImage *image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(record)]; 
     [dict setObject:image forKey:@"image"]; 
     changes = YES; 
    } 

    CFRelease(record); 
    [fullname release]; 
    } 
    CFRelease(addressBook); 
    [people release]; 

    return contacts; 
} 

に従うように、単に接触画像としてcell.imageView.imageとcell.textLabel.textを設定し、連絡先。さらなるカスタマイズが必要な場合は、すでに実装されているスタイルを避けて独自のスタイルを作成してみてください。

関連する問題