问题
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;
}
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 ?
回答1:
I personally solved it using :
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.1;
}
Instead of viewForFooterInSection:
.
回答2:
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
回答3:
You have two options to do this.
- Set tableView style to
Grouped
(UITableViewStyleGrouped
) Return the cell height like
tableViewHeight/number of cells
fromheightForRowAtIndexPath:
method:- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { int tableViewHeght = 720; return tableViewHeght * 3; }
回答4:
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
回答5:
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.
回答6:
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!
来源:https://stackoverflow.com/questions/13391615/unwanted-tablecells-showing