2010-09-16 2 views
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 [email protected]"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 [email protected]"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 protected]"Email"; 
    [cell addSubview:emailTextField]; 


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

    cell.m_rsvn_name.text [email protected]"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 [email protected]"Phone"; 
    [cell addSubview:phoneTextField]; 

    return cell; 
    } 

    if(indexPath.row == 4){ 
    cell.m_rsvn_name.text [email protected]"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 [email protected]"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 [email protected]"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 [email protected]"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; 
    [email protected]"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; 

} 

С уважением, Sathish

ответ

0

где перекрывание происходит. означает элемент ячейки или где-либо еще. и в коде где-то пользуется [ячейка addSubView] вместо этого использования [cell.contentView addSubView]

+0

hi pawan, перекрытие только в пользовательской ячейке, я имею в виду, что телефонная ячейка перекрывается с защитной ячейкой. но он не перекрывается в ячейке, отличной от cusotm. – sathish

+0

есть и изменена строка [ячейка addSubview: emailTextField]; с [cell.contentView addSubView: emailTextField]; – iOSPawan

1

Вы должны сделать заказ вид добавлен в ячейку внутри блока

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

    // deal with your custom views here 

} 

Например, этот код будет сделать один больше подменю на ячейке. Если эта ячейка получена от dequeue, у нее уже есть 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 protected]"Email"; 
    [cell addSubview:emailTextField]; 

    return cell; 
} 
Смежные вопросы