Skip to content

Commit 52e9ecc

Browse files
Gabriel Caddenfacebook-github-bot
authored andcommitted
Fix crash by implementing scrollViewDidScroll in RCTEnhancedScrollView (#54583)
Summary: 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
1 parent 4279958 commit 52e9ecc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ - (void)setDelegate:(id<UIScrollViewDelegate>)delegate
156156

157157
#pragma mark - UIScrollViewDelegate
158158

159+
- (void)scrollViewDidScroll:(__unused UIScrollView *)scrollView
160+
{
161+
// Empty implementation. This method exists to prevent crashes when the delegate splitter
162+
// forwards scrollViewDidScroll: messages to RCTEnhancedScrollView.
163+
}
164+
159165
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
160166
withVelocity:(CGPoint)velocity
161167
targetContentOffset:(inout CGPoint *)targetContentOffset

0 commit comments

Comments
 (0)