UITableView Cell Image Gets Larger On Click - ios

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.

Related

UITableView async image dynamic height jumping

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

Custom tableview scroll iOS

I need to show three/ four UI buttons and levels, two image views in a custom cell but there is a condition on the basis of that I need to hide an imageView and when it will be hidden, I need to decrease tableview size and buttons which are below of that image view that will move upward.
For that I am giving required conditions in
heightForRowAtIndexPath
and returning cells height accordingly and in tableview
CellForRowAtIndexPath
method I am hiding imageView and setting buttons positions which are below of that imageView.
The problem is that:
1) TableView is not scrolling smoothly
2) Initially at the time of scrolling down everything is working but when I
move upward then image is resizing and changing its shape. To solve that I have used AutoLayout but still it is not working.
I need your expert advice.
Thanks in advance.

Infinity backgroundView in tableView

I have UITableView with background image and then I scroll it I have parallax effect like background imageView scrolls too. Problem is that then my image finished I have tableView background. Is it possible to make infinity imageView? Like then I go through image then starts this one image from beginning.
In next few days I will add lib thay solved it and creates parallax effect under tableView
https://github.com/bizibizi/TableView-Parallax-Background
Can you show me how are you placing that image behind the TableView? I guess the hierarchy in the storyboard should be
UIView -> UIImageView -> UITableView
The size of the UIImageView and the UITableView should be the same. So when you scroll up and down the UITableViewyou could see the image in the background.
But please explain your scenario abit more so that I could suggest you something appropriate.
What Hanny means is that you need to have the tableView on top of imageView ordered in the stack of the parent view's subviews. What you can also do is stack two tableviews on top of each other, and add a touch event that moves both table view's scroll views. The image table view would contain cells that are the size of the whole view frame.

UICollectionView with subviews only redraws when reappearing

I'm currently building an app that uses a collection view showing images, among other stuff, inside cells.
The controller dequeues a cell, sets an image, and calls a method to change the frame of the image.
I change the image position and size like so:
[imageView setFrame:CGRectMake(imageViewXOrigin,
imageViewYOrigin,
imageViewWidth,
imageViewHeight)];
This is after calculating all 4 values.
After that, the controller returns the cell, and it gets drawn on screen.
The problem is that it's drawn using the old dimensions, and only after scrolling the cell out of the screen and scrolling it back in again will it display correctly. How do I fix this?
Using a standard storyboard mode is out of the question, because I want the image to be an aspect fit bottom left, which can't be accomplished by using the storyboard.
How do I fix this?

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.

Resources