Pregunta

I am trying to remove these tablecells which I am not using but don't know how. I already specified how many cells I want but these unwanted one keep showing, like so;

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
 return 3;
}

enter image description here

anyone know how to solve this? thanks in advance

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
if ([self numberOfSectionsInTableView:tableView] == (section+1))
{
    return [UIView new];
}
return nil;

but to no avail as i get a sigabrt error..why is that ?

¿Fue útil?

Solución

I personally solved it using :

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

Instead of viewForFooterInSection:.

Otros consejos

try this

 - (void) addFooter
 {
UIView *v = [[UIView alloc] initWithFrame:CGRectZero];

[self.myTableView setTableFooterView:v];

[v release];
}

You can try different options from

Eliminate extra separators below UITableView

You have two options to do this.

  1. Set tableView style to Grouped (UITableViewStyleGrouped)
  2. Return the cell height like tableViewHeight/number of cells from heightForRowAtIndexPath: method:

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
     {
       int tableViewHeght = 720;
        return tableViewHeght * 3;
     }
    

You can do Like this also

1.create a one one UITableCell class and Append that class to UITableView. 2.And your UITableView Attributes Change BackGroundColour is ClearColour

Then you can run And Show

For your reference you can use BackGround image also

I have seen answers as to use a header/footer or try using a grouped table view, all seems good and also the cleaner solutions. But I would rather opt another one. Assign your table view separator style to none. Declare an UIImageView instance in your cellForRowAtIndexPath method. Make an image of height 1px, width 320px, set it as the image of the image view, and add it as subview of cell, the y position being height of the cell. Do remember to autorelease the image view instance. Since autoreleasing of the same is done, there wont be any memory issues, and also you could decide in which all cells you have to show it, thereby making it a bit more flexible.

I was able to solve the issue by having this in my code;

 - (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return 0.01f;
 }

Hope this helps someone, peace!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top