Is there any way to preload side controllers? for example, let's say I move to index 2 I want to preload view controller at index 1 and index 3
I would love to have this feature, both to reduce the overall memory usage, by clearing the state of view controllers that are not nearby the visible view, and to prevent lag during left-and-right scrolling. Similar to Android's FragmentStatePagerAdapter.
I have exactly the same need!
Any ideas how to implement this feature?
I find a work around solution:
// MARK: - PagerTabStripIsProgressiveDelegate
override func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) {
if progressPercentage >= 1.0 && !indexWasChanged {
let leftIndex = self.currentIndex - 1
let rightIndex = self.currentIndex + 1
if leftIndex >= 0 {
let c = viewControllers[leftIndex]
if !c.isViewLoaded {
c.loadViewIfNeeded()
}
}
if rightIndex < self.viewControllers.count {
let c = viewControllers[rightIndex]
if !c.isViewLoaded {
c.loadViewIfNeeded()
}
}
}
super.updateIndicator(for: viewController, fromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: progressPercentage, indexWasChanged: indexWasChanged)
}
Just load the side childViewControllers yourself.
Most helpful comment
I find a work around solution:
Just load the side
childViewControllersyourself.