iOS - 从导航控制器

时间:2017-07-03 09:54:49

标签: ios objective-c xcode

我遇到了这个奇怪的错误:有时当我推动一个视图控制器(VC1 - > VC2)时,应用程序被冻结(它不会崩溃,只是冻结)。没有阻塞主线程。当我检查视图层次结构时,VC2实际上位于" UIParallaxDimmingView"。此外,还会调用viewDidLoadviewDidAppear

我如何呈现VC2:

VC *vc2 = [[VC alloc]initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:vc2 animated:YES];

所以问题是VC2已加载但未出现在屏幕上。以下是视图层次结构的屏幕截图,突出显示的蓝色视图是UIParallaxDimmingView,它阻止了我的所有VC2内容,VC1实际上在VC2下...

enter image description here

这是我的堆栈跟踪

0x10016b8dc <+0>:   sub    sp, sp, #0x40             ; =0x40 
0x10016b8e0 <+4>:   stp    x29, x30, [sp, #0x30]
0x10016b8e4 <+8>:   add    x29, sp, #0x30            ; =0x30 
0x10016b8e8 <+12>:  stur   wzr, [x29, #-0x4]
0x10016b8ec <+16>:  stur   w0, [x29, #-0x8]
0x10016b8f0 <+20>:  stur   x1, [x29, #-0x10]
0x10016b8f4 <+24>:  bl     0x1004105a4               ; symbol stub for: objc_autoreleasePoolPush
0x10016b8f8 <+28>:  adrp   x1, 1044
0x10016b8fc <+32>:  add    x1, x1, #0x888            ; =0x888 
0x10016b900 <+36>:  adrp   x30, 1057
0x10016b904 <+40>:  add    x30, x30, #0xd70          ; =0xd70 
0x10016b908 <+44>:  ldur   w8, [x29, #-0x8]
0x10016b90c <+48>:  ldur   x9, [x29, #-0x10]
0x10016b910 <+52>:  ldr    x30, [x30]
0x10016b914 <+56>:  ldr    x1, [x1]
0x10016b918 <+60>:  str    x0, [sp, #0x18]
0x10016b91c <+64>:  mov    x0, x30
0x10016b920 <+68>:  str    w8, [sp, #0x14]
0x10016b924 <+72>:  str    x9, [sp, #0x8]
0x10016b928 <+76>:  bl     0x1004106c4               ; symbol stub for: objc_msgSend
0x10016b92c <+80>:  bl     0x10040fc20               ; symbol stub for: NSStringFromClass
0x10016b930 <+84>:  mov    x29, x29
0x10016b934 <+88>:  bl     0x100410718               ; symbol stub for: objc_retainAutoreleasedReturnValue
0x10016b938 <+92>:  mov    x9, #0x0
0x10016b93c <+96>:  ldr    w8, [sp, #0x14]
0x10016b940 <+100>: str    x0, [sp]
0x10016b944 <+104>: mov    x0, x8
0x10016b948 <+108>: ldr    x1, [sp, #0x8]
0x10016b94c <+112>: mov    x2, x9
0x10016b950 <+116>: ldr    x3, [sp]
0x10016b954 <+120>: bl     0x10040fd28               ; symbol stub for: UIApplicationMain
0x10016b958 <+124>: stur   w0, [x29, #-0x4]
0x10016b95c <+128>: ldr    x1, [sp]
0x10016b960 <+132>: mov    x0, x1
0x10016b964 <+136>: bl     0x1004106e8               ; symbol stub for: objc_release
0x10016b968 <+140>: ldr    x0, [sp, #0x18]
0x10016b96c <+144>: bl     0x100410598               ; symbol stub for: objc_autoreleasePoolPop
0x10016b970 <+148>: ldur   w0, [x29, #-0x4]
0x10016b974 <+152>: ldp    x29, x30, [sp, #0x30]
0x10016b978 <+156>: add    sp, sp, #0x40             ; =0x40 
0x10016b97c <+160>: ret`

2 个答案:

答案 0 :(得分:0)

我设法找到了解决方案here

因此即使当前可见视图控制器是导航堆栈上唯一的VC,我的interactivePopGestureRecognizer也会启用。简单地禁用它将解决错误。

答案 1 :(得分:0)

SWIFT 3

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {


    if (navigationController.viewControllers.count > 1)
    {
         self.navigationController?.interactivePopGestureRecognizer?.delegate = self
        navigationController.interactivePopGestureRecognizer?.isEnabled = true;
    }
    else
    {
         self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
        navigationController.interactivePopGestureRecognizer?.isEnabled = false;
    }
}