2017-04-26 8 views
1

*利用可能な質問が多いので、ほとんどすべての問題を解決しましたが正解を得られませんでした。 私はカスタムテーブルビューのセルをUITableViewに追加する必要があるので、カスタムセルを作成してviewDidLoad関数に登録しました。カスタムUITableViewCellは表示されません。私の最初のカスタムセルが表示されます。他のユーザーは表示されません。

typedef enum { 
    rProduct, 
    rAddMoreItem, 
    rItem, 
    rBill, 
    rApplyCoupon, 
    rGrandTotal, 
    rBottomInfo, 
    rNumerOfRows 
} SectionType; 

    [myTableView registerNib:[UINib nibWithNibName:[FPMCartTableViewCell tableViewIdentifier] bundle:nil] 
      forCellReuseIdentifier:[FPMCartTableViewCell tableViewIdentifier]]; 

    [myTableView registerNib:[UINib nibWithNibName:[FPMAddMoreItemsTableViewCell tableViewIdentifier] bundle:nil] 
      forCellReuseIdentifier:[FPMAddMoreItemsTableViewCell tableViewIdentifier]]; 

    [myTableView registerNib:[UINib nibWithNibName:[FPMItemTableViewCell tableViewIdentifier] bundle:nil] 
      forCellReuseIdentifier:[FPMItemTableViewCell tableViewIdentifier]]; 

    [myTableView registerNib:[UINib nibWithNibName:[FPMApplyCouponTableViewCell tableViewIdentifier] bundle:nil] 
      forCellReuseIdentifier:[FPMApplyCouponTableViewCell tableViewIdentifier]]; 


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

    int noOfRows = 0; 
    switch (section) { 
     case rProduct: 
      noOfRows = 2; 
     break; 
     case rAddMoreItem: 
      noOfRows = 1; 
      break; 
     case rItem: 
      noOfRows = 3; 
      break; 
     case rBill: 
      noOfRows = 1; 
      break; 
     case rApplyCoupon: 
      noOfRows = 1; 
      break; 
     case rGrandTotal: 
      noOfRows = 1; 
      break; 
     case rBottomInfo: 
      noOfRows = 1; 
      break; 
    } 
    return noOfRows; 
} 
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return rNumerOfRows; 
} 
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return 100; 
} 
And added in the cellForRowAtIndexPath method : 
    { 

    UITableViewCell *cell; 
     switch (indexPath.section) { 
      case rProduct: 
      { 
       NSString *identifer = [FPMCartTableViewCell tableViewIdentifier]; 
       FPMCartTableViewCell *cell1 = (FPMCartTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifer]; 
       if (!cell1) 
       { 
        cell1 = [[FPMCartTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer]; 
       } 
       [self configureCell:cell1 forIndexPath:indexPath]; 
       cell = cell1; 
      } 
       break; 
      case rAddMoreItem: 
      { 
       NSString *identifer = [FPMAddMoreItemsTableViewCell tableViewIdentifier]; 
       FPMAddMoreItemsTableViewCell *cell2 = (FPMAddMoreItemsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifer]; 
       if (!cell2) 
       { 
        cell2 = [[FPMAddMoreItemsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer]; 
       } 
       cell2.backgroundColor = [UIColor redColor]; 
       cell = cell2; 
      } 
       break; 
      case rItem: 
      { 
       NSString *identifer = [FPMItemTableViewCell tableViewIdentifier]; 
       FPMItemTableViewCell *cell1 = (FPMItemTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifer]; 
       if (!cell1) 
       { 
        cell1 = [[FPMItemTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer]; 
       } 
       cell = cell1; 
      } 
       break; 
      case rBill: 
      { 
       NSString *identifer = [FPMItemTableViewCell tableViewIdentifier]; 
       FPMItemTableViewCell *cell1 = (FPMItemTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifer]; 
       if (!cell1) 
       { 
        cell1 = [[FPMItemTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer]; 
       } 
       cell = cell1; 

      } 
       break; 
      case rApplyCoupon: 
      { 
       NSString *identifer = [FPMApplyCouponTableViewCell tableViewIdentifier]; 
       FPMApplyCouponTableViewCell *cell1 = (FPMApplyCouponTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifer]; 
       if (!cell1) 
       { 
        cell1 = [[FPMApplyCouponTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer]; 
       } 
       cell = cell1; 
      } 
       break; 
      case rGrandTotal: 
      { 
       NSString *identifer = [FPMItemTableViewCell tableViewIdentifier]; 
       FPMItemTableViewCell *cell1 = (FPMItemTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifer]; 
       if (!cell1) 
       { 
        cell1 = [[FPMItemTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer]; 
       } 
       cell = cell1; 
      } 
       break; 
      case rBottomInfo: 
      { 
       if(!cell){ 
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"]; 
       } 
       cell.textLabel.text = @"Select Delivery and payment options in next step"; 
      } 
       break; 
     } 
    [cell setHidden:NO]; 
    return cell; 
    } 

しかし、最初のセルだけが見え、最後のセルは他のセルではなく単純です。 enter image description here

私がログインしようとしていますが、それは、私は、各セルのallocラインのマイナーチェンジを行ったばかりしている今、取り組んでデフォルト

(lldb) po cell 
<FPMApplyCouponTableViewCell: 0x7f97ec067e00; baseClass = UITableViewCell; frame = (0 402; 375 100); hidden = YES; autoresize = W; layer = <CALayer: 0x600000238be0>> 
+0

'numberOfSectionsInTableView'に返す実際の価値は何ですか? 'numberOfRowsInSection'は何回呼び出されますか? –

+0

@PhillipMills numberOfSectionsInTableViewは列挙型でnumberOfRowsInSectionが7回呼び出されたrNumerOfRowsを返します –

+0

列挙型ではなくnumberOfSectionsInTableViewの実際の整数値を返そうとしましたか? –

答えて

1

そのことにより、=真hiddedています。

  if (!cell1) 
      { 
       cell1 = [[FPMCartTableViewCell alloc] init]; 
      } 

あなたの努力に感謝します。

関連する問題