In the below image,

enter image description here

I want to hide separator line start Starting from the fifth,

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];

    [self.mainTableView setDelegate:self];
    [self.mainTableView setDataSource:self];
    [self.view addSubview:self.mainTableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4; //4 row
}
有帮助吗?

解决方案

Add this tableview delegate method to your code

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 
{
    return 0.001f;
}

This will show the separator line only to the rows which have content

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top