In tableview I have customcell reusable cell which overlap content of privious cell or last cell content overlap with first cell when scroll Tableview
You should set properties that depend on indexPath in viewForCell function, always.
Related
I have a TableView that its cell contains a second TableView (Nested TableView).
Inner tableView shows comments that have variable cell height. Calculate this height with UITableView.automaticDimension.
But main tableView cannot calculate it's cell height properly.
Main tableView use UITableView.automaticDimension for calculating cell height. but innerTableView doesn't show in the main tableView.
My test project download link:
dropbox.com/s/woieoi71t5kt66d/NestedTableViewTest%202.zip?dl=0
I am using a UICollectionView to show an array of images, horizontally and zoom in/out that image in the cell with the help of scroll view using constraints. But when I scroll horizontally it shows me previous cell content in the current cell. I am and not able to identify what is the problem.
CollectionView datasources
CollectionCell Class
try this when you reuse the Cell in cellForItem at
cell.imageView.Image = nil
Please share some code so that we can help you better. Meanwhile, make sure you have the following parts working correctly in your code:
Register correct UICollectionViewCell subclass with correct reuse identifier
Use the method [self.collectionView dequeueReusableCellWithReuseIdentifier:itemIdentifier forIndexPath:indexPath] and pass both the parameters correctly.
In UICollectionViewCell subclass, override prepareForReuse and reset the UI parameters there.
Override prepareForReuse in imageCell class, and set imageView.image to nil.
The contentSize of the scrollView should be as big as imageView.image.size, or just use MWPhotoBrowser
I have used this tutorial to put a collectionView inside a UITableView. https://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell-in-swift/
The UITableViewController is the dataSource & delegate for both the UITableView & the different collection views in each cell.
The problem is that I want to dynamically hide the CollectionView and to change its height to 0 whenever the collectionview is empty.
To do so, I have this code in CellForRowAtIndexPath
if (patients.paraclinicImage.count == 0){
[cell.collectionView setHidden:true];
cell.collectionViewHeight.constant = 0;
} else {
[cell.collectionView setHidden:false];
cell.collectionViewHeight.constant = 80;
}
By having this code, the collectionView shows up correctly initially. However, when scrolling fast, I will sometime have the cell load with the correct cell height, however the collection view will be empty. Refreshing the cell fixes this issue. Removing the above line of codes also fixes the issue.
Here are two images showing how the cell looks when first rendered, and after multiple scrollings (and re-renderings of the cell).
Before scrolling issue looks like below image
But After scrolling issue seems to like below one
I would appreciate any ideas you guys might have.
Debug view hierarchy showing an empty collectionView with an appropriate cell height
It is because your cell height is not updated on fast scrolling. UITableView caches the row height of indexPath just to calculate the scroll area. You need to set constraints properly and adjust the height of cell in heightForRowAtIndexPath: method.
Apply the logic inside heightForRowAtIndexPath: and your problem will be solved.
Happy Coding!!
I had the same issue. Sometimes, my collection view inside a tableviewcell wouldn't show the collectionview cells. I solved it by calling collectionView reload on main thread. I don't exactly know the reason, as I have many background calls on each cell and was reloading the tableview on main thread itself. Still, had to reload collectionview on main thread.
DispatchQueue.main.async {
cell.colViewProperties.reloadData()
}
I have tableview with these tableview cells:
- cell have some collectionview and cell have Height larger than haft of screen
- cell have other tableview inside it
When access to the last item inside cell (collection cell or tableview cell inside), i swipe right to focus on next cell. But it not jump to next cell in tableview, It jump to other item on screen
Example: i have main tableview, in this table have some cell is expanded cell which have other small tableview inside it. When this cell was expanded and i swipe right to last item of small tableview, then i swipe right again to move to next cell of main tableview view. But this time the next cell of main tableview was not focused, but some other item in screen gets focus
Could you give me the hit! Thanks a lot.
I am not like to get the cell size inside cell for row at indexpath
Please anybody help me to get the cell size.
UICollectionView IBOutlet name is collectionData;
UICollectionView is data driven, like all iOS GUI classes. Which means - you do not ask the collection view for the cell size but you tell the collection view the cell size. So, where did you tell the collection view the cell size? In the storyboard, programatically in the layout? Or in a delegate func? There you have it - your cell size.