gpt4 book ai didi

xcode - 在 iOS 13 上推送新 View 后后退按钮崩溃

转载 作者:行者123 更新时间:2023-12-01 23:38:01 25 4
gpt4 key购买 nike

我有一个应用程序在 iOS 12 上完美运行。我想在 iOS 13、XCode 11 上进行测试。我使用 Storyboard导航转场将一个 View Controller 推送到另一个 View Controller 。当我按第二页上的后退按钮(默认后退按钮)时,应用程序崩溃并产生以下错误。它发生在每个导航页面中,甚至是空 View 中。

2019-08-28 14:10:48.632540+0300 App Name[28453:400531] *** Assertion failure in -[UINavigationController _popNavigationBar:item:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3899.13.11/UINavigationController.m:8520
2019-08-28 14:10:48.642352+0300 App Name[28453:400531] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Override of -navigationBar:shouldPopItem: returned YES after manually popping a view controller (navigationController=<UINavigationController: 0x7fa22f0de000>)'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23afdbde __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff5015cb20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23afd958 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff255506f5 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 UIKitCore 0x00007fff46812310 -[UINavigationController _popNavigationBar:item:] + 379
5 UIKitCore 0x00007fff46592209 -[UINavigationBar _sendNavigationPopForBackBarButtonItem:] + 277
6 UIKitCore 0x00007fff465bf771 -[_UINavigationBarContentView __backButtonAction:] + 58
7 UIKitCore 0x00007fff46f0abc1 -[UIApplication sendAction:to:from:forEvent:] + 83
8 UIKitCore 0x00007fff468fc3e5 -[UIControl sendAction:to:forEvent:] + 223
9 UIKitCore 0x00007fff468fc72f -[UIControl _sendActionsForEvents:withEvent:] + 398
10 UIKitCore 0x00007fff468fc892 -[UIControl _sendActionsForEvents:withEvent:] + 753
11 UIKitCore 0x00007fff468fb68e -[UIControl touchesEnded:withEvent:] + 481
12 UIKitCore 0x00007fff46f450c7 -[UIWindow _sendTouchesForEvent:] + 2604
13 UIKitCore 0x00007fff46f469ce -[UIWindow sendEvent:] + 4596
14 UIKitCore 0x00007fff46f2204f -[UIApplication sendEvent:] + 356
15 UIKitCore 0x00007fff46fa18c0 __dispatchPreprocessedEventFromEventQueue + 6847
16 UIKitCore 0x00007fff46fa4386 __handleEventQueueInternal + 5980
17 CoreFoundation 0x00007fff23a60ac1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
18 CoreFoundation 0x00007fff23a609ec __CFRunLoopDoSource0 + 76
19 CoreFoundation 0x00007fff23a601c4 __CFRunLoopDoSources0 + 180
20 CoreFoundation 0x00007fff23a5aecf __CFRunLoopRun + 1263
21 CoreFoundation 0x00007fff23a5a6b6 CFRunLoopRunSpecific + 438
22 GraphicsServices 0x00007fff38016bb0 GSEventRunModal + 65
23 UIKitCore 0x00007fff46f0990f UIApplicationMain + 1621
24 App Name 0x000000010691b810 main + 112
25 libdyld.dylib 0x00007fff50fe1cf5 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

最佳答案

创建 UINavigationController 的自定义类,然后添加 UINavigationBarDelegate 如下所示,并将该类分配给您的 UINavigationController

 class MyNavigationController: UINavigationController {

override func viewDidLoad() {
super.viewDidLoad()
self.navigationBar.delegate = self
}
}

extension MyNavigationController : UINavigationBarDelegate {
public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool {
return true
}
}

关于xcode - 在 iOS 13 上推送新 View 后后退按钮崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57691136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com