CollectionView inside tableView Error

I have collectionView inside table view , when I press on the collection view sometimes the view pop to the previous VC and when I change the collection view hight to any number it works but when I deploy on real device without changing the cell hight the issue appears with the following error:

this is my code for tableviewCell

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

        if segmentControl.selectedSegmentIndex == 0{

            return 270

        }

        else{

            return 310
        }

    }

this is inside dequeResuableCell (TableView)

if isFromME{
            cell.color = .orange

            cell.isFromOthres = 0

            cell.high = 230
        }else{

            cell.color = .gray

            cell.isFromOthres = 1

            cell.high = 265

        }

and this is for collectionView Hight

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

        return CGSize(width: width , height:  (high))

    }

[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <UITableView: 0x128159000; frame = (5 110; 404 765); clipsToBounds = YES; autoresize = RM+BM; autoresizesSubviews = NO; gestureRecognizers = <NSArray: 0x600001bd6fd0>; layer = <CALayer: 0x600001561060>; contentOffset: {0, 0}; contentSize: {404, 0}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <Rino.PaymentViewController: 0x125524560>>

Accepted Answer

Most likely, the problem is not in the code you showed.

How did you create the TableView ?

How did you create the collection inside the TableView cell (I would suspect problem to be there).

What do you do when cell is selected ?

So, please show the full code of the class and explain what you created via IB (maybe adding a screen capture of the VC in the storyboard would help).

CollectionView inside tableView Error
 
 
Q