I am changing the y origin of a UIView in the first visible cell on the viewdidscroll event.
I update the position of the cell's content at every scroll so that it doesn't visually move with the cell.
When a previous cell is not visible anymore(scroll down), I cannot see the view anymore if I scroll up.
My question : How does scrolling affect the frame the of the views inside the cells ? How can I fix my problem ? (Will post code soon)
Cells get reused. When a cell scrolls off the screen it is reused for another cell scrolling into view. So you need to reset any views of the cell when it get reused.
If you have a custom cell, the prepareForReuse method should be overridden to reset any appropriate state.
Related
I have a collection view that loads images on willDisplay, and based on the image dimensions, updates the cell's image height constraint and calls performBatchUpdates on the ViewController. This however is causing my section header to slide up and disappear. What are some possible strategies to circumvent this from happening?
Note: The reason why I use performBatchUpdates is to preserve the animation when the cell expands for some other reason (label height increase.)
i have table view for showing product detail and each part is tableview cell,
in one of my tableview cell that is showing sizes and stores that has that size like this
and
when the user click on one of collection view items tableview expand to show stores.
if i update root tableviewcell constraints i need to reload that cell
after reloading collection scroll will rest
i tried beginUpdates and endUpdates for root tableview after changing constraint it will work but in some situation it will show a blank cell
what's wrong in my idea
in summary :
how to expand tableview cell without reloading and refresh cell view .i think both questions are equal
Change the constraints in the tableView and add to model the currently selected collectionViewCell and scroll to it with no animation in collectionViewCell awakeFromNib method the default value is 0 which means no animation will happen [the model I mean here is the model of the tableView from which you display every tableViewCell]
I've designed the screen to remove some views as the user scrolls down. This will also trigger an increase in height of the tableview covering for the "removed" views.
The problem is, when i scroll up, cells deque and disappear on the top edge of the old tableview height. This creates this blank gap since it deques prematurely.
How do I fix it so that it deques using the NEW top edge of the tableview?
In my app, I have added an UITableView over a ScrollView. I have disabled scrolling in table view.
So, only the scrollView Scrolls, I have adjusted the scroll view content Size with the tableView Frame. So, I can access all the cells.
Consider, there are 5 rows visible in the screen, if I tap any of the row, the didSelectRowAtIndexPath method gets called. If I scroll down, say to 6th cell and tap on it. The method doesnt gets called.
Same issues happens with UIcollectionView.
The reason why I have added so is. When I scroll the Scroll View, a view in that should get fixed in the top and the tableView behind it should go on scrolling. You might have seen in many of the apps in Android. So, I have used the ScrollView didScroll delegate to get the offset position. As per it, I will make the view to be fixed and vice versa.
Make the height of UITableView same as the content height of table.
Then set the content size of UIScrollView as the height of UITableView
Here is a brief example to demonstrate
CGRect rect = tblTopics.frame;
rect.size.height = tblTopics.contentSize.height;
tblTopics.frame = rect;
self.scrlVwFacultyDtl.contentSize = CGSizeMake(self.scrlVwFacultyDtl.frame.size.width, tblTopics.frame.size.height);
In the above example the tblTopics is the instance of UITableView and scrlVwFacultyDtl is the instance of UIScrollView
hope it will help you..
I have a UIScrollView in each UITableViewCell of my table view that lays out UIViews horizontally - kind of like the "Featured" section on Apple's App Store. When I'm setting up the UITableViewCell I call a function within the custom UITableViewCell to layout the scroll view. This loops through data assigned to that tableview cell's index path and then creates the custom views and adds them to the scroll view. However, these get mixed up when scrolling the tableview and when the tableview refreshes.
If I clear the subviews before laying them out, it does work. However, I'd like to keep the scroll position at the same point every time it shows the cells. How is this possible?
I've just added an external array that stores the current offset for each scrollview, and then manually set the offset on each scrollview everytime the tableview gets refreshed.