How can I hide row lines of UITableView from those rows, what are not used. For example, look at screenshot:
Can I show just 4 lines and hide other lines what are not used? So, I show just 4 lines and further comes white screen, not lines as now
How can I hide row lines of UITableView from those rows, what are not used. For example, look at screenshot:
Can I show just 4 lines and hide other lines what are not used? So, I show just 4 lines and further comes white screen, not lines as now
do like set your tableFooterView
frame as CGRectZero
on viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
// set as your tableFooterView frame as CGRectZero it hides the empty rows
self.tableView.tableFooterView = UIView(frame: CGRectZero)
self.tableView.backgroundColor = UIColor.clearColor()
}
//Obj-c code
TableName.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
//Swift code
tableView.tableFooterView = UIView(frame: .zero)
Use this code to hide the extra row lines.
Put this code in ViewDidLoad or in ViewWillApper
In your viewDidLoad Method include
self.localTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
In viewDidLayoutSubViews include
-(void)viewDidLayoutSubviews
{
if ([self.localTableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.localTableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.localTableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.localTableView setLayoutMargins:UIEdgeInsetsZero];
}
}
In tableView willDisplyCell delegate method include
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
here localTableView is the outlet taken from storyboard
// Swift 3
override func viewDidLoad() {
super.viewDidLoad()
tableView.tableFooterView = UIView(frame: .zero) }