I\'m trying to remove the separator for one UITableViewCell. I did the following:
- (UITableViewCell *)tableView:(UITableView *)tableView cellFo
Another way that is a bit hacky is to create the custom table view cell with a uiView that acts like separator inset. Then, hide and show that when you want to.
I created SampleTableViewCell and a nib file with label and separatorLineView
@interface SampleTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIView *separatorLineView;
@end
Then, in ViewController Class
@interface ViewController ()
@property (nonatomic) NSArray *items;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.items = @[@"A", @"B", @"C"];
[self.tableView registerNib:[UINib nibWithNibName:@"SampleTableViewCell" bundle:nil] forCellReuseIdentifier:@"SampleCell"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SampleTableViewCell *cell = (SampleTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"SampleCell" forIndexPath:indexPath];
cell.titleLabel.text = self.items[indexPath.row];
if (indexPath.row == 1) {
cell.separatorLineView.hidden = YES;
} else {
cell.separatorLineView.hidden = NO;
}
return cell;
}
@end