[iOS 15] Header buttons stop responding after pushing and popping a screen over the pager
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 58/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- ios, react-native, swift, typescript
调研方向
Start with ios/PagerViewProvider.swift and inspect how setupView() creates the hosting controller; the proposed workaround belongs in a separate PagerViewIOS15NavigationBarCompat.swift file. Reproduce push then pop on an iOS 15 simulator and check whether the navigation bar covers the header buttons. Done means the buttons respond after returning, while iOS 16 and later retain the existing behavior.
由索引模型根据 Issue 内容生成。
描述
Environment
- react-native-pager-view 9.0.4 in the repro app; the relevant code (
PagerViewProvider.setupView()) is unchanged in 9.0.9 - iOS 15.2 simulator (the reporter also reproduced it on a 15.1 device; newer iOS versions are not affected)
- React Native 0.84.1, New Architecture (Fabric)
@react-navigation/{native,stack,bottom-tabs,material-top-tabs}v7,react-native-screens4.27
Description
On iOS 15, after pushing a screen on top of a screen that contains a PagerView and then going back, the React Navigation header buttons (headerLeft / headerRight) stop responding. They never fire again for that screen.
The cause is not React Navigation. On iOS 15 UIHostingController installs SwiftUI's UIKitNavigationBarBridge, which calls -[UINavigationController setNavigationBarHidden:NO] on the enclosing navigation controller whenever the hosting view appears. react-native-screens creates an RNSContainerNavigationController with a hidden bar for the bottom-tab hasTwoStates container; the bridge re-shows an empty UINavigationBar on top of the screen — exactly over the React Navigation header — and that bar swallows every touch there.
Measured with lldb on an iOS 15.2 simulator after push → pop:
UINavigationBar in the window |
what hitTest at the header button returns |
|
|---|---|---|
| before | present at (0 47; 428 44), hidden = NO |
_UINavigationBarContentView (not the button) |
| after the proposed fix | none visible | the React Native button view |
Breakpoint trace of the cause (on -[UINavigationController setNavigationBarHidden:animated:], hidden = NO):
#0 -[UINavigationController setNavigationBarHidden:animated:]
#1 SwiftUI.UIKitNavigationBarBridge.hostingControllerWillAppear(animated:)
#2 SwiftUI._UIHostingView.viewControllerWillAppear(...)
#3 SwiftUI.UIHostingController._viewWillAppear(_:)
...
#16 -[RNSScreenContainerView attachScreen:atIndex:] ← react-native-screens re-attaches the screen on pop
Reproducible Demo
https://github.com/zewillze/react-native-pager-view-ios15-issue
- Run the repro on an iOS 15.x simulator/device.
- Tap a list row (pushes
Detailinside a@react-navigation/stack). - Go back.
- Tap the "Button" or "+" header button — nothing happens.
The screen structure matters: bottom tabs → stack (with a JS header) → material top tabs (the pager). The bottom-tab container provides the hidden UINavigationController, and the pager's UIHostingController is what triggers the bridge when it re-appears.
Optional check without touches, after step 3 — dump the window hierarchy:
po [[[UIApplication sharedApplication] keyWindow] performSelector:@selector(recursiveDescription)]
Before: a UINavigationBar at (0 47; 428 44) with hidden = NO. After the fix: none.
Proposed fix
Wrap the UIHostingController created in ios/PagerViewProvider.swift so it restores the enclosing navigation bar's hidden state around viewWillAppear.
To keep it easy to drop with iOS 15, the workaround lives in its own file (PagerViewIOS15NavigationBarCompat.swift) and every entry point returns early on iOS 16+ via if #available(iOS 16, *). Deleting that file and replacing the single call site with UIHostingController(...) is all that is needed once iOS 15 support is removed — the same isolation pattern used for the iOS 15 scrollEnabled fix (#1148).
The change is 2 files (+68/−1), preserves 9.0.9's ignoreSafeArea: true behaviour, and I have verified it on an iOS 15.2 simulator. I'll open a PR referencing this issue.
- 主要语言
- TypeScript
- 星标
- 3.4k
- 派生
- 488
- 平均合并
- 2 天 11 小时
- 30 天内合并 PR
- 26
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
callstack/react-native-pager-view 的其他 Issue
-
[iOS] Focused TextInput keeps focus and keyboard after switching pages (v9)可能已有人在做 @TaduJR 于 2 天前认领。 未关闭
难度 4/5 1-2 天 新手友好度 69/100
callstack/react-native-pager-view#1192 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 73/100
callstack/react-native-pager-view#1191 ·
维护者通常 1 天内回复
-
iOS: PagerScrollDelegate proxies to itself and overflows the stack when the weak originalDelegate dies可能已有人在做 @lvlrSajjad 于 39 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
callstack/react-native-pager-view#1146 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
callstack/react-native-pager-view#1144 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
callstack/react-native-pager-view#1141 · 1 个 reaction ·
维护者通常 1 天内回复
查看 callstack/react-native-pager-view 的全部 Issue
相似的 Issue
-
native
难度 2/5 1-3 小时 新手友好度 72/100
prime-radiant-inc/evener#4839 ·
维护者通常 1 天内回复
-
bug needs-triage
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
processone/fluux-messenger#1790 ·
维护者通常 1 天内回复
-
🛣️ Infrastructure
难度 2/5 1-3 小时 新手友好度 65/100
opencrvs/opencrvs-core#14232 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
kunchenguid/gh-axi#220 ·
维护者通常 1 天内回复