fix(ios): rename to newPresentingViewController to avoid UIKit collision

- Rename presentingViewController to newPresentingViewController
- Fixes crash caused by collision with UIViewController's presentingViewController property
- Update react-native-screens patch to use new method name
This commit is contained in:
lodev09 2025-11-24 13:54:37 +08:00
parent d2e228dfa5
commit 1d231b73f5
No known key found for this signature in database
GPG Key ID: F098AE8F7143F3E0
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm
index 51f021831aed26a4eed3c85014020423b7b3108b..62c52923b332af8f53031b7dc835df12f3c07181 100644
index 51f021831aed26a4eed3c85014020423b7b3108b..268fa69dfee2b20d8b5a66c77c1b4cbd8c831573 100644
--- a/ios/RNSScreenStack.mm
+++ b/ios/RNSScreenStack.mm
@@ -640,8 +640,10 @@ RNS_IGNORE_SUPER_CALL_END
@ -27,8 +27,8 @@ index 51f021831aed26a4eed3c85014020423b7b3108b..62c52923b332af8f53031b7dc835df12
+ UIViewController *presentingController = nil;
+
+ // Check if the external modal implements the optional method
+ if ([dismissibleModal respondsToSelector:@selector(presentingViewController)]) {
+ presentingController = [dismissibleModal presentingViewController];
+ if ([dismissibleModal respondsToSelector:@selector(newPresentingViewController)]) {
+ presentingController = [dismissibleModal newPresentingViewController];
+ }
+
+ // Only handle the non-dismissible modal if it provides a presenting controller
@ -50,7 +50,7 @@ index 51f021831aed26a4eed3c85014020423b7b3108b..62c52923b332af8f53031b7dc835df12
// We didn't detect any controllers for dismissal, thus we start presenting new VCs
diff --git a/ios/integrations/RNSDismissibleModalProtocol.h b/ios/integrations/RNSDismissibleModalProtocol.h
index 006f809d104c1d4fbdf6eccca89d6c6e190cca71..8269fdd9b483b9cc4f2be57b6b6da965033c9d9b 100644
index 006f809d104c1d4fbdf6eccca89d6c6e190cca71..89e297f1b7a9582fee3e19237dfba8d4c87a352f 100644
--- a/ios/integrations/RNSDismissibleModalProtocol.h
+++ b/ios/integrations/RNSDismissibleModalProtocol.h
@@ -1,3 +1,5 @@
@ -68,7 +68,7 @@ index 006f809d104c1d4fbdf6eccca89d6c6e190cca71..8269fdd9b483b9cc4f2be57b6b6da965
+// that should be used as the presenting controller for subsequent modals.
+// This gives the external modal implementation control over the presentation chain.
+// If not implemented or returns nil, the non-dismissible modal itself will be used.
+- (nullable UIViewController *)presentingViewController;
+- (nullable UIViewController *)newPresentingViewController;
+
@end

View File

@ -668,7 +668,7 @@
return NO;
}
- (UIViewController *)presentingViewController {
- (UIViewController *)newPresentingViewController {
// Return the content view controller as the presenting controller
// This allows react-native-screens to present modals on top of the sheet's content
// instead of trying to present on top of the sheet itself