Fix crash by implementing scrollViewDidScroll in RCTEnhancedScrollView (#54583)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54583

Fix crash by implementing the missing `scrollViewDidScroll:` method in `RCTEnhancedScrollView`.

## Root Cause

`RCTEnhancedScrollView` conforms to `UIScrollViewDelegate` and adds itself as a delegate to its delegate splitter, but only implements two delegate methods:
- `scrollViewWillEndDragging:withVelocity:targetContentOffset:`
- `scrollViewDidZoom:`

It was missing `scrollViewDidScroll:`, which is the most commonly called delegate method. When the splitter has multiple delegates, it sets itself as the UIScrollView's delegate and forwards messages to all registered delegates. When `UIScrollView` calls `scrollViewDidScroll:` on the splitter, the splitter attempts to forward it to `RCTEnhancedScrollView`, which doesn't implement it → crash: "unrecognized selector sent to instance".

## Solution

Implement an empty `scrollViewDidScroll:` method in `RCTEnhancedScrollView`.

## Changelog
[iOS][Fixed] - Fix crash in RCTEnhancedScrollView when scrollViewDidScroll is called

Reviewed By: cipolleschi, keoskate

Differential Revision: D86813725

fbshipit-source-id: dd1410ed389a4ab904d1583e1f83bb6122725b60
This commit is contained in:
Gabriel Cadden authored and meta-codesync[bot] committed 2025-11-19 11:33:47 -08:00
1 parent 427995858d
commit 5f14001e92
1 file changed
+6
@@ -156,6 +156,12 @@
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(__unused UIScrollView *)scrollView
{
// Empty implementation. This method exists to prevent crashes when the delegate splitter
// forwards scrollViewDidScroll: messages to RCTEnhancedScrollView.
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
withVelocity:(CGPoint)velocity
targetContentOffset:(inout CGPoint *)targetContentOffset