0

これはデフォルトの連絡先画像です

名簿から一度に10件の連絡先を取得またはロードするために実装したい。名簿からすべての連絡先を取得する可能性がありますが、一度に10〜10件の連絡先を表示します。すべてのiphoneの画像、名、姓を取得しています。連絡先。これを実装して、10〜10個の電子メール連絡先などの電子メール検索連絡先を電子メールで取得します。 この画像のように、取得する連絡先または電子メールの連絡先 これが私のサンプルコードです:

SData *imageData = (NSData *)CFBridgingRelease(ABPersonCopyImageDataWithFormat(ref, kABPersonImageFormatThumbnail)) ;

            CFStringRef firstName1, lastName1;


            firstName1 = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
            lastName1  = ABRecordCopyValue(ref, kABPersonLastNameProperty);
            NSString *name=[[NSString alloc]init];


            if ([[NSString stringWithFormat:@"%@",firstName1] isEqualToString:@"(null)"] && [[NSString stringWithFormat:@"%@",lastName1] isEqualToString:@"(null)"])
            {

                name = @"No Name";
            }
            else if([[NSString stringWithFormat:@"%@",firstName1] isEqualToString:@"(null)"] && ![[NSString stringWithFormat:@"%@",lastName1] isEqualToString:@"(null)"])
            {

                name = [NSString stringWithFormat:@"%@",lastName1];
            }

           else
           {
                name = [NSString stringWithFormat:@"%@",firstName1];

           }

           name= [ name  capitalizedString];

            EmailandCotactsModel *emailmodel=[[EmailandCotactsModel alloc]init];
            emailmodel.emailemailstring=(__bridge NSString *)(contno);
            emailmodel.emailusernamestring=name;


            if(!imageData)
            {
                NSString *path = [[NSBundle mainBundle] pathForResource:@"NoImage" ofType:@"png"];
                NSData *photoData = [NSData dataWithContentsOfFile:path];
                emailmodel.emailimagesData=photoData;
            }
            else
            {
                emailmodel.emailimagesData=imageData;

            }


            [emailarray addObject:emailmodel];

            callsmsDataBool=NO;

            NSLog(@"table email count %d and i %d",emailarray.count,tablecountint);
            if(emailarray.count==tablecountint)
            {

                NSLog(@"table email reload");

                tablecountint=tablecountint+10;

                dispatch_async( dispatch_get_global_queue(0,0),^{
                    [self reloadtable];
                });

                NSLog(@"perform selection in bg");

            }

        }
    }


    [self.tableview reloadData];


   if(!emailarray.count && [socialstring isEqualToString:@"Email"])
   {
       selectedlabel.text=@"Emails not found";
   }
   else if(emailarray.count && [socialstring isEqualToString:@"Email"])
   {
      // selectedlabel.text=@"Email";

       selectedlabel.text=[NSString stringWithFormat:@"%ld",nPeople];
   }
   else if(!emailarray.count && [socialstring isEqualToString:@"SMS"])
   {
       selectedlabel.text=@"Phone no's not found";
   }
   else if(emailarray.count && [socialstring isEqualToString:@"SMS"])
   {
       selectedlabel.text=@"SMS";
   }
   else
   {
        selectedlabel.text=@"";
   }

    [tableview reloadData];

貴重な提案をいただければ幸いです。

前もって感謝します。

4

1 に答える 1

1

1つの配列内のすべての連絡先を取得した後、10個の連絡先を別の配列にコピーし、このメソッドを最初に呼び出して、その新しい配列でテーブルの再読み込みメソッドを計算します。

-(void)tabledataloadingmethod
{
    for (lowerlimit=0+lowerlimit; lowerlimit<upperlimit; lowerlimit++)
    {
        if (lowerlimit<[self.array1 count])
        {
            OBJECT *obj=[self.array1 objectAtIndex:lowerlimit];
            [self.array2 addObject:obj];

        }

    }
    [self.tbleview reloadData];

}  

テーブルdelageteメソッドcellforrowatindexでこれを使用します

    if ([self.array2 count]==indexPath.row)
            {


                UITableViewCell *cell1=[self.tbleview dequeueReusableCellWithIdentifier:@"cells"];
                if(cell1==nil)
                {
                    cell1=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cells"];
                }

                cell1.textLabel.textColor = [UIColor whiteColor];
                cell1.textLabel.text=@"Loading more...";

                [self performSelector:@selector(loadmorecells) withObject:nil afterDelay:0.2];



                return cell1;
  }    
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    if ([self.array2 count]>0 && ([self.array2 count]<[self.array1 count]))
    {
        return [self.array2 count]+1;
    }
    else
    {
        return [self.array2 count];
    }
} 

ここでは、loadmorecellsメソッドの下限と上限をインクリメントします

-(void)loadmorecells
    {

        lowerlimit = upperlimit;

        upperlimit = upperlimit +10;
        [self tabledataloadingmethod];
    }
于 2013-03-09T07:10:39.110 に答える