UITableView async image dynamic height jumping - ios

I'm currently working on a project where I need to display a Facebook like feed with (depending on uploaded or not) a imageview and multiline label.
I already created a custom UITableViewCell, and the text content is showing correctly and changing the height of the cell with autolayout. But when a image is loaded into the imageview (with dynamic height), the tableview starts to jump, probably because the cell sizes are changing. I'm using SDWebImage to load the images.
Is there any way to fix this issue?
SOLUTION:
What we did is pre-load the images. Then build the tableview and cells.
Below my custom cell layout in the interface builder, the small stroke on the bottom is the dynamic image:

check this. They have explained everything in detail. Hope this helps

Related

UICollectionViewCell loaded from Xib (Nib) is being covered by storyboard cells as its size is not updating

I'm using a Xib file to hold a UICollectionViewCell item that I do not want to have in a Storyboard. I have the UICollectionView set to calculate its cell sizes automatically. But what I see when the collection view loads is that it's retaining the default 50x50 size for the cell that's being loaded from the Xib file. It's not being updated to the size it is showing up as.
The cell looks correct on screen and at the correct size. But when another cell loads that is contained in the storyboard it's loading on top of the other cell as its being placed 50 points down from the first cell.
The cell outlined in orange is the one being covered up by the one in green. I cannot show a larger portion of this due to work restrictions but I hope this clarifies what's happening.
I've tried to say that the cellNeedsLayout() and layoutIfNeeded() but neither of those make any difference. It's like the actual height that the cell is not being calculated early enough to have the collection view place cells around it correctly.
I've not been able to find a way to preload the Xib so that it already knows how large that needs to be. I am using a subclass of UICollectionView named CollectionCell.
Can anyone point me in the direction to look or suggest a fix for this other than moving what I've done into the Storyboard?

UITableViewCell with dynamically changing the heigh and adding new components?

I have a UITableViewCell which has 50px of height and I would like to change this height to 300px and to append one more view insight the new height. I did a project which you can download and test with all the code and functionality (Link to the project on DropBox). The main problem is that when the cell (random cell) is selected the height is changing correctly but the new view (with brown color) is not visible although I can print its frame, type and so on (it's not nil neither hidden). It works well if I select the first cell from the beginning and then all the rest cells work correctly. So it's something with the reusing of the cell but I couldn't find the exact solution. Thank you!

Resize UITable Header View Auto Layout

I am building a simple iOS application using Swift.
One of my views, displays a list of comments (cells in a PFQueryTableViewController...I am using Parse.com for my database).
My cells resize happily in order to fit the possible multiple-lines of the comments. This is MAGIC! (if you ask me)
What I am having trouble doing, is making the UIView which is at the top of the TableView resize based on multiple lines worth of content for the Label in that top view (see below).
Instead of doing multiline and resizing the view (I have set up constraints and set lines of text to 0), the label only shows one line, truncating it at the edge of the screen with "..."
Does anyone have any suggestions or solution for how to cause my top UIView to resize based on the content of the UILabel?
I was also thinking this could maybe better be done using a Container View at the top of the TableViewController?
There is a delegate method in UITableViewDelegate that lets you return the height of the head view (heightForHeaderInSection). You have to implement it making sure you return the proper height.
If you have a nib with constraints already, you can load the nib in a #property, and use the method systemLayoutSizeFittingSize that should give you enough height.
For more details checkout this post I wrote a while ago: Customize the UITableview with different height of cells like Facebook feeds in iOS

UICollectionView with custom UICollectionViewLayOut

I am trying to have the content in a uicollectionviewcell grow bigger when it scroll moving in one direction. i initially set the size of the cell to the largest size i want, then the content inside the cell is half in terms of the size. the content is an uiimageview.
So I have a custom UICollectionViewFlowLayout in which I subclassed the layoutAttributesForElementsInRect to make the uiimageview in the cells grow bigger when it is moving in one direction. i also have shouldInvalidateLayoutForBoundsChange to return YES
Everything works perfectly when i scroll, the imageview will grow larger. However if i select a cell to push to a new viewcontroller, and then when i click the back button to come back to this uicolletionview, the enlarged uiimageview in severals cells are showing in the original size. They can only go back to the correct enlarged size if i scroll again, why is that? and how can i make it keep its enlarged size after getting pushed?
i tried invalidatelayout but it will just refresh the layoutattributes with correct enlarged size of the content, but the view is just not updated eventhough the size is already enlarged.
thanks
I had a similar issue when designing cv cells and would gess the issue is with when the subviews get calls to update their size, which might not happen when the view refreshes.
Instead of resizing content in the cell, you might want to dynamically size the cells themselves and have the content automatically adjust to that size. Calling [mycollection invalidateLayout] then should be all you need, maybe not even that.
The method is
collectionView:layout:sizeForItemAtIndexPath:
which you declare in your UICollectionViewFlowLayout.h
If you then run into trouble where subviews do not resize with cell size, related problems can arise from constraints/autolayout etc of the subviews.

UITableView Cell Image Gets Larger On Click

I have a UITableView which loads the icons for my other apps.
They look fine at a good 57x57 automatic size in a cell which is 70px height.
When I click on a cell, the image suddenly scales up to 70x70 and I have no idea how to stop it.
Any ideas?
Thanks,
Ashley
So the way I understand it is you are adding a UIImageView as a subview to a cellview.
The way I do this that works great even where the image is smaller than the cells row hieght is add the UIImageView in cellForRowAtIndexPath then set the frame to something that fits in the cell and is the image size.
You might be building the custom cells in the UI Builder, but explicitly setting the frame of the image view to CGRectMake(imageview.frame.bounds.x,imageview.frame.bounds.y,57,57) and setting the autoresize property for vertical and horizontal to none should stop it from scaling up.

Resources