0

Crashes, UITableView with UICollectionViews inside on iOS 9, but works on ios10 while scrolling (scrollToRow) with SWIFT.

In the console, but not sure this is a only reason:

*** -[UICollectionView retain]: message sent to deallocated instance 0x7fa8fb085e00

I use auto-resizing cells for both of them.

In cellForRowAt of table view I do this:

                cell?.collectionView.tag = indexPath.row
                cell?.collectionView.delegate = self
                cell?.collectionView.dataSource = self
                cell?.selectionStyle = .none
                cell?.collectionView.reloadData()
                collectionView.collectionViewLayout.invalidateLayout()

How to properly deal with a such issue?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Dirder
  • 363
  • 2
  • 3
  • 11
  • I can't figure out when a message could be sending to the deallocated collectionView. The bug is reproduced with some periodization. – Dirder Apr 07 '17 at 21:22
  • It is difficult to understand the problem of your example. Need more code. Try this sample: http://stackoverflow.com/questions/31582378/ios-8-swift-tableview-with-embedded-collectionview/42628971#42628971 – Vasily Bodnarchuk Apr 08 '17 at 07:55
  • I've tried to move cell?.collectionView.reloadData() to UITableView, willDisplay cell: ,but it didn't help. BTW, I have 3 different types of cells with collections, maybe it influences somehow? – Dirder Apr 08 '17 at 09:50
  • I suppose it is all about some conflicts when I use 2 different kinds of table cells with collections. Because when I use only one kind it works without crashes. – Dirder Apr 08 '17 at 10:52
  • when I moved all that code from cellForRowAt to cellWillDisplay, it almost fixed the bug, but anyway it crashes sometimes.. – Dirder Apr 08 '17 at 17:02
  • Can you create full sample for me? I will fix it – Vasily Bodnarchuk Apr 08 '17 at 17:14
  • Vasily, I don't know how to do that, the project is too huge and the server side API and so on.. so it is so difficult to make sample project which will simulate real behavior... :( – Dirder Apr 08 '17 at 17:55

0 Answers0