Lazy Loading Data in iOS Carplay

后端 未结 3 1447
无人共我
无人共我 2020-12-10 08:27

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 bu

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-10 09:07

    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.

提交回复
热议问题