iosuitableviewuiscrollviewobjective-c-blocks

how to check if scrollView grinds to a halt when tabbar is clicked?


A viewcontroller is the child of tabbarcontroller, it has a tableview, when the tableview grinds to a halt, one of three methods is executed.

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if(!decelerate) {
 // stop
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
 // stop
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
// stop
}

but when I quick swipe the tableview , and at the same click the tabbaritem to change other viewcontroller as the selectedviewcontroller . none of three methods is executed。

I try my best to find a method to detect the time ,but I cannot solve it


Solution

  • I am not aware if there is any documentation for what I am writing below.

    However, I know from practical knowledge and observation that this is not possible because the scrollview will stop scrolling the moment you change the tab.

    You can validate this behaviour in all of Apple's apps that have a tabbar (Photos, AppStore, Developer) and even other prominent apps from 3rd-party devs (Youtube, Youtube Studio).

    As far as I know we do not have control over this behaviour. However, you should be able to treat the tabbarcontroller's delegate method of selected tab index change as the substitute for the scroll view delegate methods you have mentioned, specially to "detect the time" when the scroll view stops scrolling (it is at the moment when you switch to a different tab).

    You would need to ensure that the user has selected a different tab than the one they are already on.

    Also I would like to mention that I think this is not really related to tab change. I think this happens when a scrollview disappears. So you may also be able to detect this change using viewDidDisappear(_:).