-2

cellforrowatindexpath メソッドの通常の実行を混乱させることなく、Web サーバーからテーブルビューのたとえば 5 行ごとに画像を取り込むことは可能ですか? ありがとう

4

2 に答える 2

2

check in tableView:cellForRowAtIndexPath: if the indexPath.row is dividable by 5 and treat the cell differently if true (e.g. other background image, ...).

于 2012-07-18T17:29:19.270 に答える
2

サンプルコード:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    // Here is the magic.
    if (!indexPath.row % 5 == 0)
    {
        // Do your usual code
    }
    else
    {
        // Do alternate code (loading background image)
    }
    return cell;
}
于 2012-07-18T19:44:38.040 に答える