[iOS] Accessing RNSScreenView from a native module/component #1277
Replies: 2 comments 6 replies
-
Can't you add a new prop to |
Beta Was this translation helpful? Give feedback.
-
@WoLewicki I have the same question but for a different scenario. We do use We are able to get the current top-most ViewController (code below), but when we then call
So I thought it would have been much better if we could access/use react-native-screens's native NavigationController implementation, and present our native UIViewController as its The code for accessing top-most view controller extension UIApplication {
static func getTopMostController(_ fallbackTo: UIViewController? = nil) -> UIViewController? {
let viewController = fallbackTo ?? UIApplication.shared.windows.first(where: { window in
return window.isKeyWindow
})?.rootViewController
if let tab = viewController as? UITabBarController {
if let selected = tab.selectedViewController {
return getTopMostController(selected)
}
}
if let nav = viewController as? UINavigationController {
return getTopMostController(nav.visibleViewController)
}
if let presented = viewController?.presentedViewController {
return getTopMostController(presented)
}
return viewController
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've recently implemented Picture-in-Picture video playback in the app that I'm currently working on, and meanwhile it works fine, there's one thing that stands out and crushes my inner perfectionist - it obstructs core UI elements such as tab & app bars.
The fix for this is pretty simple. Parent UIViewController has a property
additionalSafeAreaInsets
, which extends base safe area inset (which covers the notch and home indicator on iPhone X and later) and instructs how system UI elements should position themselves relative to app contents.Modifying rootViewController is a no-go - this results in a shifted layout of the entire app.
But modifying screen's UIViewController in
attachScreen
does the job.This doesn't look pretty and I can't programatically update the insets.
❓ Is there a way to get access to a currently mounted screen and its view controller from an internal native module/component?
Not sure what fits best in this scenario, but I guess that implementing a native component is a better way to go with this problem, since then I could try to find and modify only the screen that renders it.
Beta Was this translation helpful? Give feedback.
All reactions