Web のどこにも見つからなかった問題があります。Nib からロードされたカスタム セルを表示する必要があります。別のスレッドで DB から情報をダウンロードし、新しい MutableArray に割り当てます。別の配列に割り当てられ、必要に応じて呼び出されるが、Web からダウンロードされない画像もあります。下にスクロールすると、テーブルビューが「遅れる」のです。つまり、正しいセルに物を配置する必要があるためです。Facebook アプリは下にスクロールするときにセルを読み込みますが (それほど遅くはありません)、スクロールして戻ると何もリロードせず、セルは既に読み込まれています (いくつであっても)。どうすればこのようなことができますか?私のテーブルは非常に遅く、(現時点では)3つのセルしかありません..
これは私のコードです:(これはviewDidLoadにあります)
NSString *strURL = [NSString stringWithFormat:@"..(myurl)..];
// to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:[strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
// to receive the returend value
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
if(![strResult isEqualToString:@"0"]) {
posts = [strResult componentsSeparatedByString:@"^"];
}
immProfilo = [NSMutableArray array];
for (int i = 0; i < [posts count]; i++) {
NSArray *datiPost = [[posts objectAtIndex:i] componentsSeparatedByString:@"/"];
FBProfilePictureView *fotoProfiloFB = [[FBProfilePictureView alloc] initWithFrame:CGRectMake(22, 22, 55, 55)];
fotoProfiloFB.profileID = [datiPost objectAtIndex:1];
[immProfilo addObject:fotoProfiloFB];
}
[self.postTab reloadData];
そして、それは私のテーブルビューコードです:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)postTab {
return [posts count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"%ld_%ld",(long)indexPath.section,(long)indexPath.row];
PostTabCell *cell = (PostTabCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"PostTabCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
NSString *annuncio = [posts objectAtIndex:indexPath.section];
datiAnnuncio = [annuncio componentsSeparatedByString:@"/"];
[cell addSubview:[immProfilo objectAtIndex:indexPath.section]];
cell.nome.text = [datiAnnuncio objectAtIndex:0];
cell.location.text = [self getAddressFromLatLon:[[datiAnnuncio objectAtIndex:2] floatValue] withLongitude:[[datiAnnuncio objectAtIndex:3] floatValue]];
cell.testoPost.text = [datiAnnuncio objectAtIndex:4];
return cell;
}