0

グループ化された UITableView の読み込みに時間がかかります。このトピックに関する他の投稿をいくつか読みましたが、パフォーマンスを改善するものを見つけることができませんでした。コードを再設計する際に正しい方向に向けてくれる人を探しています。

8 つのセクションと 32 のセルがあります。セルは、5 つの異なるカスタム UITableView Cell サブクラスのいずれかに属します。サブクラスにはサブビューが含まれており、IB を使用してまとめられています。

TableView データは、セル タイプ、ラベル、および UINavigationController によってプッシュされるビュー コントローラー リンクに関する情報も含む plist から生成されます。xml ファイルのサンプルを以下に示します。複雑な pList が問題の一部である可能性はありますか?

<dict>
        <key>Header</key>
        <string>Property Information</string>
        <key>Data</key>
        <array>
            <dict>
                <key>TableView</key>
                <string>informationTable</string>
                <key>Link</key>
                <string>ROIPropertyInfoUIViewController</string>
                <key>Entity</key>
                <string></string>
                <key>Image Name</key>
                <string>runtime</string>
                <key>Cell Type</key>
                <string>ROIUITableViewCellType3</string>
                <key>Label</key>
                <string>runtime</string>
            </dict>
        </array>
    </dict>

cellForRowAtIndexPath別の潜在的な問題は、plist ファイルに書かれている内容に応じてロードする UITableViewCell のクラスを決定する非常に長いメソッドです。これが要因になるのでしょうか?

解析コードは次のとおりです。

-(void)setPlistFilename:(NSString *)pList forTableView:(UITableView *)tableView

if (tableView==mainTableView) {
        NSString *path = [[NSBundle mainBundle] pathForResource:pList ofType:@"plist"];
        self.mainTableDataArray = [[NSArray alloc ] initWithContentsOfFile:path];
        NSLog(@"count of mainTableArray is %d", mainTableDataArray.count);
}

[tableView setDataSource:self]; [tableView setDelegate:self];

[tableView setSectionFooterHeight:0];
[tableView setSectionHeaderHeight:0];

}

これが私のcellForRowAtIndexPath方法の一部です:

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    NSMutableArray *tmpDataSet = [[NSMutableArray alloc]init];


    if (tableView==self.mainTableView) {
        int section = [indexPath section];
        tmpDataSet = [[self.mainTableDataArray objectAtIndex:section] valueForKey:@"Data"];
    }


         //**Figure out the cell type
    NSString *cellTypeString = [[tmpDataSet objectAtIndex:[indexPath row]] valueForKey:@"Cell Type"];
    NSLog(@"cell type string is %@", cellTypeString);
//***Create the different types of cells depending on what is listed in the pList***
    if ([cellTypeString isEqualToString:@"ROIUITableViewCellType1"]) {
        ROIUITableViewCellType1 *c = [tableView dequeueReusableCellWithIdentifier:cellTypeString];

        if(!c)
        {
            c = [[ROIUITableViewCellType1 alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellTypeString];

        }
      //  mainTableViewHeight += [ROIUITableViewCellType1 retrunCellHeight];
        NSLog(@"mainTableViewHeight = %f", self.mainTableViewHeight);

        return [self setCellContentFromDataArray:tmpDataSet forCell:c forIndexNumer:[indexPath row]];

テーブルには 1 つの画像のみが含まれ、ネットワークからデータは読み込まれません。何を修正するのに時間を費やすべきかについてアドバイスをお願いします。

4

0 に答える 0