I would like to eliminate the space in these two places programatically?
I have tried this without much luck:
- (CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
return 35.50;
}
- (CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section {
return CGFLOAT_MIN;
}
UPDATE:
I have seen this solution and it doesn't help me.
After applying the suggested solution of
self.yourTableView.sectionHeaderHeight = 0
self.yourTableView.sectionFooterHeight = 0
I get this, but thats not correct. The whole section title is gone.
It looks like your cell have margin
Open Debug>Debug view hierarchy and see where is your margin
Why you return 35.5 in the heightForHeaderInSection? It is your header height?
Try this and remove heightForHeaderInSection and heightForHeaderInSection functions from your UITableViewDelegate:
self.yourTableView.sectionHeaderHeight = 0
self.yourTableView.sectionFooterHeight = 0
Or this
-
(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
return 0;
}
- (CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section {
return 0;
}
I give you clear reference from below link
Click Here
Credit goes to Tomen
Related
The 2 rows on top (Monthly, Annual) are a different section than the 3rd row at the bottom (Lifetime). I want to remove the space that is above the Lifetime row in between the sections. I tried changing the header height to 1.0 in the heightForHeaderInSection method but it didn't seem to work.
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
CGFloat headerHeight = 0.0;
switch (section) {
case 0:
headerHeight = [self featuredProductHeaderView].frame.size.height;
break;
case 1: {
if (_groupOneSectionTitle) {
headerHeight = 1.0;
}
}
You need to set the footer height as well, and make sure you are not returning a title for header/footer nor are you returning a view for header/footer.
Sorry i know this question has been asked before but i can't seem to get it to work, i would like to change the height of the first cell in my UITableView and keep the rest as default 44. I have implemented the below code (tried various others) and my application builds but the cell height does not change. Any help on this would be great.
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 150;
}
else {
return 44;
}
}
How did this code work out for you?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0)
return 150;
else
return 44;
}
estimatedHeightForRowAtIndexPath
is used to calculate the position / size of the scroll bar on the side when using autoLayout, not the cell height. You need:
heightForRowAtIndexPath
I have a simple UITableView (sample project here) but the section headers do not respect the height I'm setting in the heightForHeaderInSection
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 40;
}
The table view looks like this. The 1 section header has a correct height but not the other ones.
When I inspect the view with the Reveal app, it seems that there is a kind of footer after the last cell in the section.
What am I doing wrong?
What seems to work is this
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.0001f; // 0.0f does not work
}
or even better, in loadView
self.tableView.sectionFooterHeight = 0.0f;
Swift:
Swift version of approved answer:
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return CGFloat.leastNonzeroMagnitude
}
Guessing into the blue and from your inside with the Reveal App try setting the footer to height 0.
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0;
}
According to the docs:
Special Considerations
Prior to iOS 5.0, table views would
automatically resize the heights of footers to 0 for sections where
tableView:viewForFooterInSection: returned a nil view. In iOS 5.0 and
later, you must return the actual height for each section footer in
this method.
These two pictures should explain it. The first shows my UITableView normally. The second shows when I touch the UISearchBar and it takes focus. Why is there a gap between the cell header and the search bar? Anyone know how to fix this?
iOS 7 is when this occurs by the way. I already have this code:
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{
return 0;
}
else
{
return 23;
}
}
I fixed this problem in my code by removing the following 2 lines of code.
self.viewController.edgesForExtendedLayout = UIRectEdgeNone;
self.navigationBar.translucent = NO;
Hope that leads you in the right direction.
In iOS 7 there is small area on the top of UITableView. This is the header of UITableView.
Add following code to your controller ( UITableViewDelegate class ).
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 1;
}
I have a basic grouped table view where i have implemented the two methods for setting header and footer for each section. Now, the header text is showing and working just fine. But the text in the footer view is not showing. I have 3 sections and only want to add text to the first footer section. The code:
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
if ( section == 0 ) {
return #"Lorem ipsum";
}
return nil;
}
Now the weird thing is that it seems that the table is actually making space for the text, it's just not showing. I think there might be some really simple explanation to this, but can't seem to find it:)
I guess you are having heightForFooterInSection method in your viewController. If you are returning any value here, it is the problem. If you are doing, change your code like
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if (section == 0) {
return 30.0f;
}
return 0.0f;
}