0
iosアプリケーションを実行すると、最初のセルのみがTableViewに表示され、2番目のセルが表示されます。私はそれらを両方同時に表示することを希望しますが、私はこの動作を把握することはできません。ここでTableviewで最初のセルが選択された後にのみ表示される2番目のセルios
は私のビューのコードがロード
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ProductCellId";
ProductTableCell *cell =
(ProductTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"ProductTableCell" owner:self options:nil];
cell = self.productCell;
}
Product *product = [products objectAtIndex:indexPath.row];
[cell configureForProduct:product];
return cell;
}
すべてのヘルプははるかに高く評価されるだろうやったです!
お返事ありがとうございます。 my(cell == nil)条件がこの{[[NSBundle mainBundle] loadNibNamed:@ "ProductTableCell" owner:self options:nil]; cell = self.productCell; }それは私が記述した振る舞いをします。私が(cell == nil){cell [= [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; }アプリは単にクラッシュします。それ以上の提案はありますか?再度、感謝します! – mikez
@Mikezなぜアプリケーションがクラッシュするのですか?エラーは何ですか?私はProductTableCellがUITableViewサブクラスだと仮定していますので、[[ProductTableCell alloc]を行う必要があります。つまり、デキューでClassCastExceptionが発生してクラッシュする可能性があります。私の答えを新しいコードで編集しました。 –
さて、私はこのラインセル= [[ProductTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]を使用しました。それはクラッシュしなかったが、リストは完全に空だった – mikez