Error when refreshing a view: received layout atts for cell with index path that does not exist


#1

I have a page (Page1) that loads data into a radlistview. Using iOS. The user can go to another page (Page2) and make some new selections, and then go back to Page1 and Page1 should refresh the data to show the new selections. Right now, I am using this method on Page1:

import {Page} from "tns-core-modules/ui/page";
...
constructor(private page: Page){
   this.page.on('navigatingTo', (data) => {  
      this.loadNewData();
  })

loadNewData(){
 /*get newly selected data and insert it into the radlistview */
}

However, I am getting an error when the Page1 ui tries to refresh after the back button on Page2:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist

How can I get rid of this error?

Looks like in iOS others (like here ) address this with code like: self.collectionView.collectionViewLayout.invalidateLayout()

But that is obj-C. I’m hoping for a JS method.

Or is there a better way to refresh the data that won’t cause error?


#2

Did you try navigatedTo instead of navigatingTo?


#3

That seems to be working. Thanks for the suggestion. Any reason why “navigatedTo” would work and not “navigatingTo” ?


#4

navigatingTo is fired while starting navigation, native views may not be ready yet by the time.


How to catch navigating away from page (Angular, ios)
Call function every time you visit page (even if got there by a back button press)
#5

Very helpful–that saved me a lot of time. Thanks, @manojdcoder .