Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear (a separator color) in particular section in tableview (iPhone)?

Currently i am working in iPhone application, using tableview to develop the tables and its style like grouped, No.of section like 2, then the 1st section has separator color like lightgray color and the 2nd section has separator color like clearColor. but when i scrolled the table view, sometimes 2nd section active at the time 1st section also clear a separator color, How to fix this? Please any one help me

Thanks in Advance

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

       if (indexPath.section == 0 && indexPath.row == 0) 
        {
            studentUpdateTable.separatorColor = [UIColor lightGrayColor];
            cell.backgroundColor = [UIColor whiteColor];
        }
       else if(indexPath.section == 1 && indexPath.row == 0)
       {
            studentUpdateTable.separatorColor = [UIColor clearColor];
            cell.backgroundColor = [UIColor clearColor];
       }
}
like image 261
SampathKumar Avatar asked Nov 28 '25 08:11

SampathKumar


2 Answers

 tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

you can just set to to None instead of trying to set it to clearColor

like image 128
janusfidel Avatar answered Nov 30 '25 22:11

janusfidel


This did works

cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];

Added a custom UIView (newly allocated UIView) as the cell's background view.

like image 38
SampathKumar Avatar answered Nov 30 '25 21:11

SampathKumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!