Queen Solutions
Queen Solutions

Reputation: 253

how to remove the line below the tableView cell in iphone

I have iphone app in which i am adding tableView and inside tableView cell i am adding the textfield but problem is that it shows line below the textfiled in tableView as shown in the image attached here is the my code.

enter image description here

I want to remove the line which is coming below the input filed Enter Tag Here

-(UITableViewCell *)tableView:(UITableView *)atableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  if(!cell) {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
   // cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"tabelsales.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
    //cell.backgroundColor = [UIColor clearColor];
   }

   for (UIView *subView in cell.subviews)
   {
    if (subView.tag == 2 || subView.tag == 22) 
    {
        [subView removeFromSuperview];
    }
   }



  tableView.backgroundView=nil;


   if(indexPath.section==0){
    tagInputField =[[UITextField alloc]initWithFrame:CGRectMake(0,1,249,28)];



    tagInputField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    tagInputField.textAlignment=UITextAlignmentLeft;

    tagInputField.backgroundColor=[UIColor whiteColor];

    tagInputField.tag = 2;
    tagInputField.delegate = self;
    tagInputField.clearButtonMode = UITextFieldViewModeWhileEditing;


    tagInputField.font=[UIFont fontWithName:@"Myriad-Pro" size:8];
    [tagInputField setText:@"Enter tag here "];
    tagInputField.textColor =[UIColor grayColor];
    [cell addSubview:tagInputField];
    if(tagArray.count >0)
    {

        [tagInputField setBorderStyle:UITextBorderStyleNone];





    }
    else {
          [tagInputField setBorderStyle:UITextBorderStyleRoundedRect];





    }


    return cell;
    }

   if(indexPath.section==1) {
    UIButton *crossButton =[[UIButton alloc]initWithFrame:CGRectMake(228, 8, 18, 18)];
    crossButton.tag = 22; //use a tag value that is not used for any other subview
    //crossButton.backgroundColor = [UIColor purpleColor];
    crossButton.backgroundColor  = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Cross.png"]];
    [cell addSubview:crossButton];
    cell.textLabel.font =[UIFont fontWithName:@"Myriad-Pro" size:8];
    cell.textLabel.textColor =[UIColor grayColor];

    cell.backgroundColor=[UIColor whiteColor];

    cell.textLabel.text =[tagArray objectAtIndex:indexPath.row];
    [crossButton addTarget:self action:@selector(deleteCell:) forControlEvents:UIControlEventTouchUpInside];

    [tagInputField setFrame:CGRectMake(8,1,240,30)];

    tableView.backgroundColor=[UIColor whiteColor];







    [publishButton setFrame:CGRectMake(40,560,250, 50)];

    [descriptionTextImageView setFrame:CGRectMake(48,450,250,90)];






    return cell;
    }

Upvotes: 0

Views: 921

Answers (3)

Dhaval Bhadania
Dhaval Bhadania

Reputation: 3089

Update:

1) set property of tableview separatorStyle as UITableViewCellSeparatorStyleNone.

2) set property of SeparatorColor like:

   [self.tableView setSeparatorColor:[UIColor clearColor]];

3) other simple way to remove seprator is add custom seprator to simple UIView of 1px height:

  UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
  separatorLineView.backgroundColor = [UIColor clearColor]; // as per your requirement set color.
  [cell.contentView addSubview:separatorLineView];

4) write this delegate method of tableview:

 - (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 
   { 
       return 0.01f;// here remove your footer
   }

  - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
     {
       // To "clear" the footer view
       return [[UIView new] autorelease];
     }

5) try this one:

   self.tblView=[[UITableView alloc] initWithFrame:CGRectMake(0,0,320,460) style:UITableViewStylePlain];
   self.tblView.delegate=self;
   self.tblView.dataSource=self;
   [self.view addSubview:self.tblView];

   UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];
   v.backgroundColor = [UIColor clearColor];
   [self.tblView setTableHeaderView:v];
   [self.tblView setTableFooterView:v];
   [v release];

Upvotes: 2

josh
josh

Reputation: 1689

It can be from xib. Set separator to None, as below screen shot show. Hope it will help. Thanks Tableview from xib

Upvotes: 1

Harshil
Harshil

Reputation: 209

You should set separatorStyle property of UITableView to UITableViewCellSeparatorStyleNone.

Upvotes: 0

Related Questions