2009-03-30 21 views
8

私は実際のデバイスで初めてテストしていますが、明らかなパフォーマンス上の問題を修正した後、どのようにスムーズにスクロールするかについては固執しています。UITableViewでスロースクロールを解決する方法

これは私が何をすべきかです:

  • データは、私は、各ヘッダ配列にDbの
  • からのIDのリストを持っている、ヘッダ
  • の小さな配列を持ってsqliteの
  • であります

ヘッダA Ids = 1,2; ヘッダーB Idsは= 3,4

  • は私怠惰な負荷がセル&
  • はかろうじて10の項目が
  • ロードが速い時にロードされたデータを取得するためのオブジェクトは、スクロールのみが問題です

これは、セルのローディング上のコードである:

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

    ProductCell *cell = (ProductCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 
     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ProductCell" owner:self options:nil]; 

     cell = [nib objectAtIndex:0]; 
    } 

    // Set up the cell... 
    Product *p = [self locateRecord:indexPath]; 

    cell.nameLabel.text = [p.name capitalizedString]; 
    cell.codeLabel.text = p.ref; 

    if ([self.selectedProducts objectForKey:[NSNumber numberWithInt:p.Id]]) { 
     OrderDetail *d = [self findDetail:p]; 

     cell.qty.text = [NSString stringWithFormat:@"%ld",[d.qty integerValue]]; 
    } 

    return cell; 
} 

- (id) locateRecord:(NSIndexPath *)indexPath { 
    NSNumber *theId; 
    NSUInteger pos = [indexPath row]; 

    id o; 

    if (self.results) { 
     theId = [self.results objectAtIndex:pos]; 
    } else { 
     NSString *key = [[self.index objectAtIndex:[indexPath section]] objectAtIndex:0]; 
     NSArray *data = [self.cache objectForKey:key]; 

     theId = [data objectAtIndex:pos]; 
    } 

    Db *db= [Db currentDb]; 

    o = [db loadById:[self returnItemClass] theId:[theId intValue]]; 

    return o; 
} 

答えて

5
  1. プリロードデータ
  2. Do your own drawing
+0

だから、これはそれが細胞のレイアウトには、一切使用インターフェイスビルダーではありません意味ですか? – mamcx

+0

Twitterのようなスクロール速度が必要な場合は、私のゲストになります。テーブルをバターのようにスクロールさせたい場合は、独自の描画を行います。 =) –

+0

私はそれが怖いと思うが、それは全く難しいことではない。このコメントは –

関連する問題