表视图单元格重叠问题

发布于 2024-09-24 00:21:12 字数 11181 浏览 3 评论 0原文

我在使用以下代码时遇到重叠问题。我为此表单使用了自定义单元格和普通单元格样式。

任何建议表示赞赏

 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{



 static NSString *RSVNIdentifier = @"RSVNCell";

 CreateReservationViewCell *cell = (CreateReservationViewCell *)[tableView dequeueReusableCellWithIdentifier:RSVNIdentifier] ;




 if (cell == nil) {
  cell = [[[CreateReservationViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RSVNIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
 } 





 if(indexPath.section == 0)
 {
  {

   if(indexPath.row == 0){
    //cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.editing =NO;
    cell.m_rsvn_name.text =@"Customer";
    cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"reservation"] objectForKey:@"createdBy"];
    cell.m_rsvn_value.enabled=NO;

    return cell;
   } 
   if(indexPath.row == 1){

    cell.m_rsvn_name.text =@"Till";
    cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"reservation"] objectForKey:@"createdDate"];
    cell.m_rsvn_value.enabled=NO;
    return cell;
   } 
   if(indexPath.row == 2){
    //cell.selectionStyle = UITableViewCellSelectionStyleNone;
    emailTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
    emailTextField.adjustsFontSizeToFitWidth = YES;
    emailTextField.font = [UIFont systemFontOfSize:12];
    emailTextField.textAlignment= UITextAlignmentRight;
    emailTextField.keyboardType= UIKeyboardTypeEmailAddress;
    emailTextField.returnKeyType = UIReturnKeyDone;
    emailTextField.tag=0;
    emailTextField.delegate=self;
    emailTextField.text =[textFields objectAtIndex:0];
    cell.m_rsvn_name.text =@"Email";
    [cell addSubview:emailTextField];


    return cell;
   } 
   if(indexPath.row == 3){

    cell.m_rsvn_name.text =@"Telephone";
    phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
    phoneTextField.adjustsFontSizeToFitWidth = YES;
    phoneTextField.font = [UIFont systemFontOfSize:12];
    phoneTextField.textAlignment= UITextAlignmentRight;
    phoneTextField.keyboardType= UIKeyboardTypePhonePad;
    phoneTextField.delegate=self;
    phoneTextField.tag=1;
    phoneTextField.text =[textFields objectAtIndex:1];

    cell.m_rsvn_name.text =@"Phone"; 
    [cell addSubview:phoneTextField]; 

    return cell;
   } 

   if(indexPath.row == 4){
    cell.m_rsvn_name.text =@"Internal Note";
    cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"reservation"] objectForKey:@"internalNote"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.m_rsvn_value.enabled=NO;
    return cell;
   } 



  }




 }
 else if(indexPath.section == 1){

  NSLog(@"%@",unit_details);


  //[[create_reservation_detail objectAtIndex:0] objectForKey:@"reservation"] objectForKey:@"unitName"];

  for (int i=0; i<[unit_details count]; i++) {

   if(indexPath.row == i){
    cell.m_unit_title.text = [[unit_details objectAtIndex:0] objectForKey:@"unitName"];
    cell.m_unit_value1.text = [[unit_details objectAtIndex:0] objectForKey:@"nights"];
    cell.m_unit_value2.text =[[unit_details objectAtIndex:0] objectForKey:@"adults"];
    return cell;
   } 
  }



 }


 else if(indexPath.section == 2){

  if(indexPath.row == 0){

   cell.m_rsvn_name.text = @"Total Charges";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"totalRoomCharge"];
   return cell;
  }
  if(indexPath.row == 1){

   cell.m_rsvn_name.text = @"10%  Tax";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"roomTaxAmount"];
   return cell;
  }
  if(indexPath.row == 2){

   cell.m_rsvn_name.text = @"Total  Charges1";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"otherCharge"];
   return cell;
  }
  if(indexPath.row == 3){

   cell.m_rsvn_name.text = @"Total Charges2";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"totalCharge"];
   return cell;
  }
  if(indexPath.row == 4){

   cell.m_rsvn_name.text = @"Total Payments";
   //cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"totalPayment"];

   return cell;
  }
  if(indexPath.row == 5){

   cell.m_rsvn_name.text = @"Current Balance";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"currentBalance"];

   return cell;
  }


 }
 else  if(indexPath.section == 3){

  if(indexPath.row == 0){

   cell.m_rsvn_name.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"description"];
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"amount"];
   return cell;

  }
  else if(indexPath.row == 1){
   cell.m_rsvn_name.text =@"Amount Due";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"amount_due"];
   return cell;
  }

  else if(indexPath.row == 2){
   cell.m_rsvn_name.text =@"Security Deposit status";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"securityStatus"];
   return cell;
  }

  else if(indexPath.row == 3){
   cell.m_rsvn_name.text  =@"Security Deposit Due";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"securityStatus_due"];
   return cell;
  }

  else if(indexPath.row == 4){
   static NSString *SecurityCellIdentifier = @"Cell";

   UITableViewCell *security_cell = [tableView dequeueReusableCellWithIdentifier:SecurityCellIdentifier];
   if (security_cell == nil) {
    security_cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SecurityCellIdentifier] autorelease];
   }

   // Configure the cell...
   security_cell.textLabel.text = @"Security Deposit Instruction:";
   security_cell.textLabel.font = [UIFont systemFontOfSize:14];
   security_cell.detailTextLabel.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"instruction"];
   security_cell.textLabel.font = [UIFont systemFontOfSize:14];

   security_cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
   security_cell.detailTextLabel.numberOfLines = 0;



   [security_cell.detailTextLabel sizeToFit];
   return security_cell; 

  }

 }
 else  if(indexPath.section == 4){

  static NSString *Payment_CellIdentifier = @"Payment_Cell";

  UITableViewCell *pay_cell = [tableView dequeueReusableCellWithIdentifier:Payment_CellIdentifier];

  if (!pay_cell) {
   pay_cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Payment_CellIdentifier] autorelease];
  }
  pay_cell.textLabel.font=[UIFont systemFontOfSize:14];


  if(indexPath.row == 0){

   if ([[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"paypal"] isEqualToString:@""]) 
   {
    pay_cell.accessoryType=UITableViewCellAccessoryNone;

    pay_cell.selectionStyle = UITableViewCellSelectionStyleNone;

   }
   else
   {
    pay_cell.accessoryType = UITableViewCellAccessoryCheckmark;
   }
   NSLog(@"accessory type ->%d",cell.accessoryType);

   pay_cell.textLabel.text = @"PayPal";
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
            pay_cell.detailTextLabel.text=[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"paypal"];
   pay_cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
   pay_cell.detailTextLabel.numberOfLines = 0;
   [pay_cell.detailTextLabel sizeToFit];


   return pay_cell;

  }

  if(indexPath.row == 1){

   if ([[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"manualCheck"] isEqualToString:@""]) 
   {
    pay_cell.accessoryType=UITableViewCellAccessoryNone;

    pay_cell.selectionStyle = UITableViewCellSelectionStyleNone;
   }
   else
   {
    pay_cell.accessoryType = UITableViewCellAccessoryCheckmark;
   }
   NSLog(@"accessory type ->%d",cell.accessoryType);
   pay_cell.textLabel.text = @"Manual Check";
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
            pay_cell.detailTextLabel.text=[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"manualCheck"];
   pay_cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
   pay_cell.detailTextLabel.numberOfLines = 0;

   [pay_cell.detailTextLabel sizeToFit];
   return pay_cell;
  }
  if(indexPath.row == 2){

   if ([[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"tranfer"] isEqualToString:@""]) 
   {
    pay_cell.accessoryType=UITableViewCellAccessoryNone;
    NSLog(@"accessory type ->%d",UITableViewCellAccessoryCheckmark);
    pay_cell.selectionStyle = UITableViewCellSelectionStyleNone;

   }
   else
   {
    pay_cell.accessoryType = UITableViewCellAccessoryCheckmark;

   }
   NSLog(@"accessory type ->%d",UITableViewCellAccessoryCheckmark);
   pay_cell.textLabel.text = @"Wire / Transfer";
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
            pay_cell.detailTextLabel.text=[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"tranfer"];
   pay_cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
   pay_cell.detailTextLabel.numberOfLines = 0;
   [pay_cell.detailTextLabel sizeToFit];

   return pay_cell;
  }
  if(indexPath.row == 3){


   other.borderStyle=UITextBorderStyleRoundedRect;
   other.placeholder=@"other\n";
   other.autocorrectionType=UITextAutocorrectionTypeNo;
   other.delegate=self;
   other.autocapitalizationType=UITextAutocapitalizationTypeNone;
   other.hidden=[[textFields objectAtIndex:2] intValue];
   other.returnKeyType = UIReturnKeyDone;



   [pay_cell addSubview:other];


   pay_cell.textLabel.text = @"Other";
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;

   return pay_cell;
  }


 }
 else {
  if(indexPath.row == 0){
   static NSString *Button_CellIdentifier = @"Button_Cell";

   UITableViewCell *button_cell = [tableView dequeueReusableCellWithIdentifier:Button_CellIdentifier];

   if (button_cell == nil) 
   {
    button_cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:Button_CellIdentifier] autorelease];

   } 

    button_cell.backgroundView= [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"save_reservation_button.png"]] autorelease]; 

    button_cell.selectedBackgroundView= [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"save_reservation_button.png"]] autorelease];  


   return button_cell;
  }
 }


 return nil;

}

问候, 萨蒂什

I am getting overlapping issue while using following code. I used custom cell and normal cell style for this form.

Any suggestion is appreciated

 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{



 static NSString *RSVNIdentifier = @"RSVNCell";

 CreateReservationViewCell *cell = (CreateReservationViewCell *)[tableView dequeueReusableCellWithIdentifier:RSVNIdentifier] ;




 if (cell == nil) {
  cell = [[[CreateReservationViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RSVNIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
 } 





 if(indexPath.section == 0)
 {
  {

   if(indexPath.row == 0){
    //cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.editing =NO;
    cell.m_rsvn_name.text =@"Customer";
    cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"reservation"] objectForKey:@"createdBy"];
    cell.m_rsvn_value.enabled=NO;

    return cell;
   } 
   if(indexPath.row == 1){

    cell.m_rsvn_name.text =@"Till";
    cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"reservation"] objectForKey:@"createdDate"];
    cell.m_rsvn_value.enabled=NO;
    return cell;
   } 
   if(indexPath.row == 2){
    //cell.selectionStyle = UITableViewCellSelectionStyleNone;
    emailTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
    emailTextField.adjustsFontSizeToFitWidth = YES;
    emailTextField.font = [UIFont systemFontOfSize:12];
    emailTextField.textAlignment= UITextAlignmentRight;
    emailTextField.keyboardType= UIKeyboardTypeEmailAddress;
    emailTextField.returnKeyType = UIReturnKeyDone;
    emailTextField.tag=0;
    emailTextField.delegate=self;
    emailTextField.text =[textFields objectAtIndex:0];
    cell.m_rsvn_name.text =@"Email";
    [cell addSubview:emailTextField];


    return cell;
   } 
   if(indexPath.row == 3){

    cell.m_rsvn_name.text =@"Telephone";
    phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
    phoneTextField.adjustsFontSizeToFitWidth = YES;
    phoneTextField.font = [UIFont systemFontOfSize:12];
    phoneTextField.textAlignment= UITextAlignmentRight;
    phoneTextField.keyboardType= UIKeyboardTypePhonePad;
    phoneTextField.delegate=self;
    phoneTextField.tag=1;
    phoneTextField.text =[textFields objectAtIndex:1];

    cell.m_rsvn_name.text =@"Phone"; 
    [cell addSubview:phoneTextField]; 

    return cell;
   } 

   if(indexPath.row == 4){
    cell.m_rsvn_name.text =@"Internal Note";
    cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"reservation"] objectForKey:@"internalNote"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.m_rsvn_value.enabled=NO;
    return cell;
   } 



  }




 }
 else if(indexPath.section == 1){

  NSLog(@"%@",unit_details);


  //[[create_reservation_detail objectAtIndex:0] objectForKey:@"reservation"] objectForKey:@"unitName"];

  for (int i=0; i<[unit_details count]; i++) {

   if(indexPath.row == i){
    cell.m_unit_title.text = [[unit_details objectAtIndex:0] objectForKey:@"unitName"];
    cell.m_unit_value1.text = [[unit_details objectAtIndex:0] objectForKey:@"nights"];
    cell.m_unit_value2.text =[[unit_details objectAtIndex:0] objectForKey:@"adults"];
    return cell;
   } 
  }



 }


 else if(indexPath.section == 2){

  if(indexPath.row == 0){

   cell.m_rsvn_name.text = @"Total Charges";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"totalRoomCharge"];
   return cell;
  }
  if(indexPath.row == 1){

   cell.m_rsvn_name.text = @"10%  Tax";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"roomTaxAmount"];
   return cell;
  }
  if(indexPath.row == 2){

   cell.m_rsvn_name.text = @"Total  Charges1";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"otherCharge"];
   return cell;
  }
  if(indexPath.row == 3){

   cell.m_rsvn_name.text = @"Total Charges2";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"totalCharge"];
   return cell;
  }
  if(indexPath.row == 4){

   cell.m_rsvn_name.text = @"Total Payments";
   //cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"totalPayment"];

   return cell;
  }
  if(indexPath.row == 5){

   cell.m_rsvn_name.text = @"Current Balance";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"charges"] objectForKey:@"currentBalance"];

   return cell;
  }


 }
 else  if(indexPath.section == 3){

  if(indexPath.row == 0){

   cell.m_rsvn_name.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"description"];
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"amount"];
   return cell;

  }
  else if(indexPath.row == 1){
   cell.m_rsvn_name.text =@"Amount Due";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"amount_due"];
   return cell;
  }

  else if(indexPath.row == 2){
   cell.m_rsvn_name.text =@"Security Deposit status";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"securityStatus"];
   return cell;
  }

  else if(indexPath.row == 3){
   cell.m_rsvn_name.text  =@"Security Deposit Due";
   cell.m_rsvn_value.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"securityStatus_due"];
   return cell;
  }

  else if(indexPath.row == 4){
   static NSString *SecurityCellIdentifier = @"Cell";

   UITableViewCell *security_cell = [tableView dequeueReusableCellWithIdentifier:SecurityCellIdentifier];
   if (security_cell == nil) {
    security_cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SecurityCellIdentifier] autorelease];
   }

   // Configure the cell...
   security_cell.textLabel.text = @"Security Deposit Instruction:";
   security_cell.textLabel.font = [UIFont systemFontOfSize:14];
   security_cell.detailTextLabel.text =[[[create_reservation_detail objectAtIndex:0] objectForKey:@"deposit"] objectForKey:@"instruction"];
   security_cell.textLabel.font = [UIFont systemFontOfSize:14];

   security_cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
   security_cell.detailTextLabel.numberOfLines = 0;



   [security_cell.detailTextLabel sizeToFit];
   return security_cell; 

  }

 }
 else  if(indexPath.section == 4){

  static NSString *Payment_CellIdentifier = @"Payment_Cell";

  UITableViewCell *pay_cell = [tableView dequeueReusableCellWithIdentifier:Payment_CellIdentifier];

  if (!pay_cell) {
   pay_cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Payment_CellIdentifier] autorelease];
  }
  pay_cell.textLabel.font=[UIFont systemFontOfSize:14];


  if(indexPath.row == 0){

   if ([[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"paypal"] isEqualToString:@""]) 
   {
    pay_cell.accessoryType=UITableViewCellAccessoryNone;

    pay_cell.selectionStyle = UITableViewCellSelectionStyleNone;

   }
   else
   {
    pay_cell.accessoryType = UITableViewCellAccessoryCheckmark;
   }
   NSLog(@"accessory type ->%d",cell.accessoryType);

   pay_cell.textLabel.text = @"PayPal";
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
            pay_cell.detailTextLabel.text=[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"paypal"];
   pay_cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
   pay_cell.detailTextLabel.numberOfLines = 0;
   [pay_cell.detailTextLabel sizeToFit];


   return pay_cell;

  }

  if(indexPath.row == 1){

   if ([[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"manualCheck"] isEqualToString:@""]) 
   {
    pay_cell.accessoryType=UITableViewCellAccessoryNone;

    pay_cell.selectionStyle = UITableViewCellSelectionStyleNone;
   }
   else
   {
    pay_cell.accessoryType = UITableViewCellAccessoryCheckmark;
   }
   NSLog(@"accessory type ->%d",cell.accessoryType);
   pay_cell.textLabel.text = @"Manual Check";
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
            pay_cell.detailTextLabel.text=[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"manualCheck"];
   pay_cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
   pay_cell.detailTextLabel.numberOfLines = 0;

   [pay_cell.detailTextLabel sizeToFit];
   return pay_cell;
  }
  if(indexPath.row == 2){

   if ([[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"tranfer"] isEqualToString:@""]) 
   {
    pay_cell.accessoryType=UITableViewCellAccessoryNone;
    NSLog(@"accessory type ->%d",UITableViewCellAccessoryCheckmark);
    pay_cell.selectionStyle = UITableViewCellSelectionStyleNone;

   }
   else
   {
    pay_cell.accessoryType = UITableViewCellAccessoryCheckmark;

   }
   NSLog(@"accessory type ->%d",UITableViewCellAccessoryCheckmark);
   pay_cell.textLabel.text = @"Wire / Transfer";
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;
            pay_cell.detailTextLabel.text=[[[create_reservation_detail objectAtIndex:0] objectForKey:@"payment"] objectForKey:@"tranfer"];
   pay_cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
   pay_cell.detailTextLabel.numberOfLines = 0;
   [pay_cell.detailTextLabel sizeToFit];

   return pay_cell;
  }
  if(indexPath.row == 3){


   other.borderStyle=UITextBorderStyleRoundedRect;
   other.placeholder=@"other\n";
   other.autocorrectionType=UITextAutocorrectionTypeNo;
   other.delegate=self;
   other.autocapitalizationType=UITextAutocapitalizationTypeNone;
   other.hidden=[[textFields objectAtIndex:2] intValue];
   other.returnKeyType = UIReturnKeyDone;



   [pay_cell addSubview:other];


   pay_cell.textLabel.text = @"Other";
   pay_cell.selectionStyle = UITableViewCellSelectionStyleGray;

   return pay_cell;
  }


 }
 else {
  if(indexPath.row == 0){
   static NSString *Button_CellIdentifier = @"Button_Cell";

   UITableViewCell *button_cell = [tableView dequeueReusableCellWithIdentifier:Button_CellIdentifier];

   if (button_cell == nil) 
   {
    button_cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:Button_CellIdentifier] autorelease];

   } 

    button_cell.backgroundView= [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"save_reservation_button.png"]] autorelease]; 

    button_cell.selectedBackgroundView= [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"save_reservation_button.png"]] autorelease];  


   return button_cell;
  }
 }


 return nil;

}

Regards,
sathish

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我ぃ本無心為│何有愛 2024-10-01 00:21:12

您应该将自定义视图添加到块内的单元格中,

if (cell == nil) {
  cell = [[[CreateReservationViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RSVNIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

   // deal with your custom views here

 } 

例如,此代码将在单元格上再创建一个子视图。如果此单元格来自出队,则它已经在此单元格上添加了一个 emailTextField,并且以下代码将在此单元格上再添加一个 emailTextField。

if(indexPath.row == 2){
    //cell.selectionStyle = UITableViewCellSelectionStyleNone;
    emailTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];

    ... // assign emailTextField settings

    cell.m_rsvn_name.text =@"Email";
    [cell addSubview:emailTextField];

    return cell;
 }

You should make custom view added to cell inside the block

if (cell == nil) {
  cell = [[[CreateReservationViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RSVNIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

   // deal with your custom views here

 } 

For example, this codes will make one more sub-views on the cell. If this cell is come from dequeue, it already has a emailTextField added on this cell, and following code will add one more emailTextField on this cell.

if(indexPath.row == 2){
    //cell.selectionStyle = UITableViewCellSelectionStyleNone;
    emailTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];

    ... // assign emailTextField settings

    cell.m_rsvn_name.text =@"Email";
    [cell addSubview:emailTextField];

    return cell;
 }
极度宠爱 2024-10-01 00:21:12

发生重叠的地方。意味着在单元格项目或其他任何地方。并在代码中使用 [cell addSubView] 而不是使用 [cell.contentView addSubView]

where overlapping is happening. means on cell item or anywhere else. and in code somewhere u using [cell addSubView] instead of that use [cell.contentView addSubView]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文