views:

30

answers:

2

Hi team,

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

A: 

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]

pawan.mangal
hi pawan, the overlapping only in custom cell i mean phone cell is overlapping with security deposit due cell. but it doesnt overlapping in non-cusotm cell.
sathish
have u changed line [cell addSubview:emailTextField]; with [cell.contentView addSubView:emailTextField];
pawan.mangal
A: 

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;
 }
Toro