我有一个基于故事板的应用程序,为此我创建了自定义segues,它使用我创建的自定义动画控制器。
当一次向前/向后移动一个屏幕时,一切正常。但是,当我尝试通过一堆屏幕放松时(例如,我已经使用了First-> Second->第三,然后尝试放开第三个>第一个),我收到EXC_BAD_ACCESS (code=1)
错误。< / p>
UIViewController.dismissViewControllerAnimated(https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/dismissViewControllerAnimated:completion :)的Apple文档说明
如果您连续呈现多个视图控制器,从而构建一堆呈现的视图控制器,则在堆栈中较低的视图控制器上调用此方法会解除其直接子视图控制器以及堆栈上该子视图上方的所有视图控制器。发生这种情况时,只有最顶层的视图以动画方式被删除;任何中间视图控制器都可以从堆栈中删除。最顶层的视图使用其模态过渡样式被忽略,这可能与堆栈中较低的其他视图控制器使用的样式不同。
据我所知,如果我在First上调用'dismissViewControllerAnimated',它应该使用其模态转换样式关闭Third,并从堆栈中删除Second。
因此我的UnwindSegue.perform方法是:
- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
UIViewController *destinationViewController = self.destinationViewController;
sourceViewController.modalPresentationStyle = UIModalPresentationFullScreen;
sourceViewController.transitioningDelegate = self;
[destinationViewController dismissViewControllerAnimated:YES completion:nil]; //Error occurs here
}
最后一行因EXC_BAD_ACCESS
错误而崩溃。
我已经做了一些挖掘(通过启用僵尸),看起来UIViewController内部对我的'前向'segue有一个弱引用 -
FirstController.dismissViewControllerAnimated
调用UIViewController._customAnimatorForDismissedController
,调用segue Second-&gt; Third(不再存在)上的方法。
任何人都不知道这种行为是否是预期的,或者我哪里出错了?一切都适用于iOS7。
ETA:崩溃日志
Incident Identifier: 821DC9AC-E1A1-4CCD-8A3F-718577C1634D
CrashReporter Key: 35442db1a2bdce63197d4abe696619ca29fe9675
Hardware Model: iPad4,1
Process: TestProject [3792]
Path: /private/var/mobile/Containers/Bundle/Application/B56179DF-3A3D-4C57-A5A0-910EF0BAEB8D/TestProject.app/TestProject
Identifier: com.xyz.TestProject
Version: 1 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2015-02-10 17:32:35.524 +0000
Launch Time: 2015-02-10 17:32:15.301 +0000
OS Version: iOS 8.1.2 (12B440)
Report Version: 105
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000554fbeb8
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000197cd7bd0 objc_msgSend + 16
1 UIKit 0x000000018bb83c3c -[UIViewController _customAnimatorForDismissedController:] + 80
2 UIKit 0x000000018bb83a84 -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 620
3 UIKit 0x000000018bb2c074 -[UIViewController dismissViewControllerWithTransition:completion:] + 948
4 UIKit 0x000000018bb2bc5c -[UIViewController dismissViewControllerAnimated:completion:] + 248
5 TestProject 0x00000001000cd768 -[XYZUnwindStoryboardSegue perform] (XYZUnwindStoryboardSegue.m:26)
6 UIKit 0x000000018ba90d30 -[UIApplication sendAction:to:from:forEvent:] + 92
7 UIKit 0x000000018ba79e44 -[UIControl _sendActionsForEvents:withEvent:] + 608
8 UIKit 0x000000018ba906cc -[UIControl touchesEnded:withEvent:] + 588
9 UIKit 0x000000018ba90358 -[UIWindow _sendTouchesForEvent:] + 696
10 UIKit 0x000000018ba898ac -[UIWindow sendEvent:] + 680
11 UIKit 0x000000018ba5cfa4 -[UIApplication sendEvent:] + 260
12 UIKit 0x000000018bcfbf54 _UIApplicationHandleEventFromQueueEvent + 14988
13 UIKit 0x000000018ba5b50c _UIApplicationHandleEventQueue + 1612
14 CoreFoundation 0x00000001872629e8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
15 CoreFoundation 0x0000000187261c8c __CFRunLoopDoSources0 + 260
16 CoreFoundation 0x000000018725fd3c __CFRunLoopRun + 708
17 CoreFoundation 0x000000018718d0a0 CFRunLoopRunSpecific + 392
18 GraphicsServices 0x00000001902f35a0 GSEventRunModal + 164
19 UIKit 0x000000018bac23bc UIApplicationMain + 1484
20 TestProject 0x00000001000ce7ec main (main.m:14)
21 libdyld.dylib 0x0000000198332a04 start + 0
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x0000000198430c94 kevent64 + 8
1 libdispatch.dylib 0x0000000100141254 0x100130000 + 70228
2 libdispatch.dylib 0x0000000100132ef4 0x100130000 + 12020
Thread 2:
0 libsystem_kernel.dylib 0x000000019844bc78 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x00000001984e5390 _pthread_wqthread + 988
2 libsystem_pthread.dylib 0x00000001984e4fa4 start_wqthread + 0