Lazy Loading Data in iOS Carplay


How to lazy load the items while the user scrolling in Carplay ?

I am using beginLoadingChildItems from MPPlayableContentDataSource to load the first set of items but how I can call the next page when a user scrolls to the bottom of the page?

enter image description here

Source: Ios

Categorised as carplay, ios, objective-c, swift


CarPlay does not support infinite scrolling by default. There is no callback when the last item on the list is displayed. However, the solution by @amr-el-sayed is an interesting one, since CarPlay will preload categories when they first appear on the screen. Thus, if the last item on the list is a category, CarPlay will call beginLoadingChildItemsAtIndexPath with the indexpath of the last item on the list, which could be used to simulate infinite scrolling. In that case, it becomes necessary to call MPPlayableContentManager reloadData because the preload is actually being called for the nested category (which is not displayed), rather than the category for which you are trying to implement infinite scrolling. This can result in some flash, as CarPlay must now redraw the entire UI. If possible, a better solution is simply to load a long list of items initially. Note that CarPlay will enforce a limit of enforcedContentItemsCount when MPPlayableContentManager.contentLimitsEnforced is true, for example, when a vehicle is in motion.

Oscar Gutmann

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us