Uitableview showing row behind HeaderView ios - ios

I'm working on UITableView.
In that when there is one row in the tableview at that time I'm getting weird. The first row hides behind headerView of UITableView.
As you can see in below image
This is what happening. I'm using autolayout and having constraint also. I can't understand where exactly the issue is.

It seems that you have transparent headers - in case you have sticky headers, this might give you some problems when scrolling.
Your problem probably lies in the header height - check if the height your tableview returns for the header in the first section has the right height (and not 0 or 1 pixel).

Thanks #ALL For giving your answers to my question.
Actually there was constraint problem. I gave the constraint priority to low. and this causes the issue.
I changed it with Required. and it works now perfectly.
Thanks again.

this might happen if your view's height for header is larger than the headers size.
Or it might happen if your cell is implemented in .xib and the contents are going above the coordinates of the visibility.
If you can post the implementation code and snapshots of your interface it might help us to give you more appropriate answer

Related

UITableView scroll on top of cell (or how to keep a cell static)

Recently I've been trying to implement the following behavior in my own app:
As you see, when you scroll the table view up, the first cell remains at its place while others scroll up and overlap it.
Have been searching for a solution for a couple of days and so far I've only found solutions that involve using headers. But the issue is that headers "stick" to the top whereas I need first cell to stay static.
Also had an idea about using a top constraint to keep the cell at place but don't quite understand how to approach this type of thing.
Any ideas how to implement that? Any help will be much appreciated!

Group TableView,using self sizing section header,after reload,if I scroll upward ,tableview will jump

I am doing a tableview like this: a twitter and comments on it;
enter image description here
I have tried several architecture.I do not find enough question and discussion about this. I think it is a very meaningful question,so I post these architectures' performance and limitations.
First,using whole cell as twitter with comments,which comments view will generate according to the model.Cell use self-sizing auto-layout height.
This architecture can work.But if a twitter have many comments(30,or more),in old iPhone(4s,5,5s and so on),fps will down to 40.Obvious block for scroll smooth.This performance bottleneck is the only weakness for this architecture.
Second,because of performance bottleneck,I think maybe I could put a comment tableview in a twitter cell.And twitter cell and embedded comment cell use self-sizing auto-layout height,too.But after try,I found that twitter cell can not confirm its height because the embedded comment tableview can not confirm its height itself.So I need to calculate the embedded comment tableview's height to confirm the twitter cell's height. This architecture works well,too.But its performance bottleneck is the same as first architecture.
Third,also the most improtant,using section header as twitter,cell as comment.That is,a section is a whole twitter with comments.Section header and cell both use self-sizing auto-layout height.
This architecture's performance is best,even twitter with as many as 50+ comments,tableview scrolls very smooth even in iPhone5,fps is at least 55.But there is strange problems that I can not solve.
I scroll to the bottom,tableview will reload next page.After reloadData,first little problem is that section header dismiss,but appear after scroll(Later I found that if I set tableview header,this problem appear,if I remove tableview header,this problem disappear,so confused).Second and more important problem is that if I scroll upward,tableview will "jump".Below is the gif demonstration.(I do not know how to post big gif to StackOverflow,I am sorry)
https://github.com/yutanchi/GroupTableViewSectionHeaderJump/blob/master/tableviewjump.gif
I think the reason is that tableview use the estimated section header height but not the actural section header height. I have searched much information but nothing can help me.I am so confused that If section header's self-sizing mechanism is the same as cell's self-sizing mechanism.Why self-sizing cell can perform the right behavior,self-sizing section header do not.
Because this architecture have obvious performance advantage,I want to make certain what's wrong with self-sizing section header,solve these annoying problems and use the architecture.Can someone explain or discuss this?
For this you have to give all constrains left right top bottom to all elements.
Also
1-in viewDidLoad set following
self.yourtableView.estimatedRowHeight= your estimated_height_for_Cell
yourtableView.rowHeight = UITableViewAutomaticDimension
2-set number of rows to zero For Labels in attribute inspector.

UICollectionView resizes cells incorrectly after reloadData

I have a UICollectionView that renders some autosizing cells. When I load the data into the collection view initially, the data is perfectly sized the way it should be.
I have a weird issue where, when I trigger reloadData with a new data set, the auto sizing goes wrong and I end up with incorrectly sized cells.
Images attached.
I have tried invalidating the collectionViewLayout before I call reloadData.
Oddly enough, if I remove data, and trigger a reloadData the cells resize to their correct layout. So I am wondering if this is a view recycling issue?
Thanks in advance.
Below is the layout after the screen was initially loaded for the first time.
Below is the layout after the + opens a modal to add a new post, closes, and refreshes the data - see incorrect sizing of cell "Thanks for all your hard work".
Below is the screen after the screen was reloaded from scratch again.
My answer might be a bit late, but getting the similar behaviour I did manage to solve it.
In my case, the problem was with multiline labels — so changing them to single-line solved the case.
As I didn't need to have multilines — I had no further research on them.
I hope, this answer could be a good starting point to find a fix.

iOS: Tableview with custom cells does not scroll

I'm using a nav bar orchestrated set of tableviewcontrollers to display a hierarchy of data. The bottom level of data is displayed in a custom tableviewcell, which has its content described in a xib, and results in a required cell height larger than the default. I posted another question on how to programmatically extract the resulting cell height, but no usable answers, so I now implement heightForRowAtIndexpath to return a hardcoded value that is the height in the xib attributes panel. But, when the table is displayed with more rows than can fit in the normal display size (480h,320w), the bottom row is chopped off as expected, but I can't scroll it to see the rest of the row. I've searched rather extensively, but nothing has helped. I poked at various attributes (tableview sizes, scrollingEnabled, etc.) but they all seem as expected values (e.g., scrollingEnabled is true). One post suggested that no scrolling would occur unless the contentSize was larger then the frame, so I looked at those values, and it sounds promising, in that my frame size is a typical 460h x 320w, but, my contentSize is 0 x 0! Further searching (e.g., "setting contentSize" or "contentSize is 0") didn't clear anything up. I thought contentSize was computed for free from the table row count and their heights, so how could I be getting 0? Even going back to allowing a default row height by not implementing heightForRowAtIndexpath still resulted in a 0 contentSize. Some searches suggest turning off autoLayout for the custom table cell, but still the same. So, what might be going awry? Thanks for any thoughts or guidance.
Update: Sorry, I confess! I had originally been developing on a mac mini with a regular USB mouse, where scrolling in the simulator was left button down and drag. I recently switched to an iMac with the magic mouse. I'm now so used to just dragging my finger on the mouse to scroll code, web pages, etc., that I didn't think to try clicking and holding the left mouse "button", and then dragging the mouse. When I did, everything worked as expected. I had really thought things were hopeless when any similar variables/values in the app on the mini were equal to those on the iMac, but it was just me getting tricked by fancy technology. Sorry for the distraction.
set your tableView's frame and your cell's frame correct,and implement
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath in your UITableView to give a right height. If that doesn't work try set your tableView.autoresizingMask to UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
which can help you with the size of the tableview
I had a similar problem. My tableView would't scroll when the content exceeded the tableViews frame.
The problem for me was that I had "Use Autolayout" checked but no constrains on the tableView. Adding vertical and horizontal space constrains on the tableView fixed my problem

Increasing the width of UITableViewCell in a grouped TableView layout

I am trying to get rid of the cell margin on the left and right of a set of cells within a group.
I have looked around and have found this question/answer
but this seems like it could cause plenty of problems down the track.
I also tried changing the cell.indentationWidth and cell.indentationLevel but these seem to change the indentation within the cell, not the cell itself.
Is there an Apple approved way of changing these cells to stretch the width of the Tableview??
Thank you in advance, your help is much appreciated.
Scott
Do one thing. add label or any other control in this and then add that in your UITableviewcell.
Then you can give whatever format you want according to your need.

Resources