Tvd
Tvd

Reputation: 4601

iOS Remove extra space below UITableView

I found this question answered earlier on stack overflow and on other sites too. I tried all options, but yet their is white space below the table. I have 4 prototype cells in my tableview. On storyboard, their is no white space after the 4th cell. But on execution I find white space after the 4th row. Their is no more separator after 4th row, but blank white are is still their. I tried adding the following code :

- (void)viewDidLoad  {
   [super viewDidLoad];

   _menuItems = [[NSMutableArray alloc] initWithObjects:@"chats", @"visitors", @"agents", @"profile", nil];   //@[@"chats", @"visitors", @"agents", @"profile", nil];
   self.tableView.tableFooterView = [UIView new];  //[[UIView alloc] initWithFrame:CGRectZero];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.menuItems count];
}

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

-(UIView *)tableView: (UITableView *) tableView viewForFooterInSection:(NSInteger)section {
    return [UIView new];
}

To make the whole view look proper, I have set same background color for view and tableview. Everything looks proper except this white area,
Can anyone help me know why do I still l see white area after the last row ? Any help is highly appreciated. Thanks.

Upvotes: 1

Views: 2911

Answers (1)

Tvd
Tvd

Reputation: 4601

MY RowHeight of TableView (44) and TableViewCell (51) was different. I changed the RowHeight of TableView to 51.

And made the Height of TableView which was 220 to 204 (51*4).

Making the RowHeight same and setting tableView Height exactly as RowHeight * number of Rows works for such kind of problem as solution.

Hope this helps someone.

Upvotes: 2

Related Questions