Increasing space between Table View header and cell on storyboared - ios

I'm migrating my app to iOS 7, what I have notice is that the space between Table View header and cell is small.
I think this normal behaviour f iOS 7? right.
I was look better before, Is there away to increase space in static UITableView designed using storyboared.

I think this normal behaviour f iOS 7? right.
Yes it is normal behaviour.
Is there away to increase space in static UITableView designed using
storyboard?
In StoryBoard Select tableview then changing the value under the Attributes Inspector .

For all of them which are not finding #Virus answer useful and if you have dynamic headers height for section follow this method
//This method returns the height of a header at a specific section
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
//For example you define heights for these sections
switch (section)
{
case 0:
return 12.0f;
break;
case 1:
return 23.0f;
break;
case 2:
return 56.0f;
break;
case 3:
return 33.0f;
break;
default:
return 25.0f;
break;
}
}
Hope it helps

Related

Change viewForHeaderInSection if that header is on top

I have UITableView with two sections. Now, because I wanted additional space for header between 0 and 1st section, I've gave them different heights:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
switch (section) {
case 0:
return 30;
break;
case 1:
return 60;
default:
return 0;
break;
}
}
Now, this is working pretty good, I have space view and then in last 30px of view I have label. Problem is when that view is scrolled on top, there is 30px spacing between navigationBar and label(that space view that I made).
Is there any way to detect is header of section 1 is scrolled to top and change height for it if it's on top?
Try to change your tableview to group style
tableView.style = UITableViewStyle.Grouped
After I reviewed what I could do, I've removed this space view and added height for footer in section 0.

UITableView is jumpy/choppy/jerky when scrolling up

I encountered this problem when using UITableView, the tableView's cells have different heights, and the auto layout constraints are set properly. When you scroll down to the bottom of tableView and load more data (no matter by using reloadData or insertRowsAtIndexPaths), and then scroll up, the tableView will start to be jumpy at some point, and then be jumpy all the time until you scroll to the very top.
Not only for my own project, I find this project on github (link) have the same problem so that you can reproduce it.
Did you solve the problem? I finally solved this issue, the key is to calculate an estimated height. Seems like the more accurate estimate you return, the less jumpiness/choppiness.
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (yourTypeOfCell) {
case something:
return estimatedHeight;
break;
case default:
return defaultValue;
break;
}
}

Tableview Header issue

I'm trying to give space between cells in my tableview for that i written the following code:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
switch (section)
{
case 0:
return 0.0f;
break;
default:
return 15.0f;
break;
}
return 15.0f;
}
up to now everything is fine, but after scrolling tableview gap is not moving when it reaches to top to table. My screens are:
You should not use header view for this purpose. Just design you cells so that their subviews (labels, buttons, images...) are contained in a view that is smaller than the cell itself and centered horizontally. Make the cell background grey, and the subviews' view container white.
The header stops at the top because you have the table style set as plain. If you change the table style to group it will scroll off the top as you are hoping.
So go to the attribute inspector for the tableView and change to style group.

Table View, Static Cells, changing Cell Height

I understand that using a dynamic TableView, you can set the Cell Height using...
tableView:heightForRowAtIndexPath:
However, if I am using A Static Table View ( not Dynamic), With Sections, I would like to programmatically set the height of a cell to 0.
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//used to set the height of a cell
CGFloat result;
switch(indexPath.section) {
case 0:
{
//How do I get the ROW number in this section?
result = 44;
break;
}
case 1:
{
//this works if I want to set all of the rowels to this height.
result = 250;
break;
}
}
The question asked another way, If I have the indexPath.section... how can I do something like...
indexPath.Section.row?
You can use indexpath.row directly. No need to write indexPath.Section.row.
In iOS, the NSIndexPath gets extra duties. It is a bit confusing as Apple has two different pieces of documentation.
As noted in the other answers, you get:
Getting the Section Index
section property
Getting the Index of a Row or Item
row property
item property

heightForRowatIndexPath does not set cell height

I am trying to create a grouped table view with 3 groups, and each group has cells that are a different height. I've set up 3 prototype cells in my Storyboard with the appropriate heights, and have set up my UITableViewController to return the appropriate heights for each row. However for some reason all of my cells are only 1 pixel tall when they appear on screen.
I've stepped through the code and the correct height and cell is returned for each row. I've also verified that the frame of each cell is correct before it is returned. However calling rectForRowAtIndexPath reveals that the rect for each row is only 1 pixel tall.
This problem goes away entirely when using a constant cell height. In that situation the cells display perfectly, some of them are just too short/tall since they should be variable height.
Any ideas what is going on here? I'd like to undertand how the rect for each row is determined when using heightForRowAtIndexPath.
Code for heightForRowAtIndexPath:
- (NSInteger)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
case 0:
return 80.0;
break;
case 1:
return 260.0;
break;
case 2:
return 110.0;
break;
case 3:
return 114.0;
break;
default:
break;
}
return 0;
}
You have declared tableView:heightForRowAtIndexPath: to return NSInteger.
That should be CGFloat.
simply to increase the height for row .simply write the method for height for row at indexpath an simply written
if (indexpath.section== 0)
return 50;

Resources