gpt4 book ai didi

iOS解雇ModalViewController导致EXC_BAD_ACCESS

转载 作者:行者123 更新时间:2023-12-02 02:50:54 25 4
gpt4 key购买 nike

调用dismissModalViewController会间歇性地导致EXC_BAD_ACCESS。

间歇性与特定的构建有关,而不是与特定的运行有关。也就是说,如果可执行文件已编译,则调用要么始终通过,要么始终失败。

它似乎并不取决于代码是否在构建之间发生了变化。

我们使用的是 iPhone 5.1 模拟器和安装了 iOS 5.1 的第 4 代 iPod touch。此行为在模拟设备和物理设备中均存在

有人见过这个吗?我们已经无计可施了。

这里是模态视图 Controller 的呈现和消失的地方:

PaymentStack* paymentStack = 
[[PaymentStack alloc] initWithOrder:[anOrderManager thisOrder] locationState:[appData locationState]
successBlock:^{
//Push the current order on the history list
[[appData ordersHistory] addObject:[anOrderManager thisOrder]];
if ([[anOrderManager thisOrder] isEffectivelyEqual:[anOrderManager thisOrder]])
{
//Allocate a new order
[anOrderManager setOrder:[[Order alloc] init]];
}
}
completionBlock:^{

[self dismissViewControllerAnimated:YES
completion:^{
NSLog(@"Complete.");
}];
}
cancellationBlock:^{
[self dismissViewControllerAnimated:YES
completion:^{
NSLog(@"Cancellation.");
}];
}];
[self presentModalViewController:[paymentStack navigationController] animated:YES];

这是堆栈跟踪:

#0  0x00d659ab in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] ()
#1 0x00b4ea9c in -[UIViewController _dismissViewControllerWithTransition:from:completion:] ()
#2 0x00b4df91 in -[UIViewController dismissViewControllerWithTransition:completion:] ()
#3 0x00b4ec81 in -[UIViewController dismissViewControllerAnimated:completion:] ()
#4 0x00071135 in __35-[MasterViewController placeOrder:]_block_invoke_0186 at /Users/jake/Documents/Avocado/AvocadoTest1.0/MasterViewController.m:258
#5 0x000515c0 in __91-[PaymentStack initWithOrder:locationState:successBlock:completionBlock:cancellationBlock:]_block_invoke_0 ()
#6 0x000545c8 in __27-[PaymentStack showSuccess]_block_invoke_0230 ()
#7 0x000558cc in -[PaymentCompleteViewController done] ()
#8 0x01a47e99 in -[NSObject performSelector:withObject:withObject:] ()
#9 0x00a8214e in -[UIApplication sendAction:to:from:forEvent:] ()
#10 0x00cc0a0e in -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] ()
#11 0x01a47e99 in -[NSObject performSelector:withObject:withObject:] ()
#12 0x00a8214e in -[UIApplication sendAction:to:from:forEvent:] ()
#13 0x00a820e6 in -[UIApplication sendAction:toTarget:fromSender:forEvent:] ()
#14 0x00b28ade in -[UIControl sendAction:to:forEvent:] ()
#15 0x00b28fa7 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#16 0x00b28266 in -[UIControl touchesEnded:withEvent:] ()
#17 0x00aa73c0 in -[UIWindow _sendTouchesForEvent:] ()
#18 0x00aa75e6 in -[UIWindow sendEvent:] ()
#19 0x00a8ddc4 in -[UIApplication sendEvent:] ()
#20 0x00a81634 in _UIApplicationHandleEvent ()
#21 0x03dd9ef5 in PurpleEventCallback ()
#22 0x01a1a195 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#23 0x0197eff2 in __CFRunLoopDoSource1 ()
#24 0x0197d8da in __CFRunLoopRun ()
#25 0x0197cd84 in CFRunLoopRunSpecific ()
#26 0x0197cc9b in CFRunLoopRunInMode ()
#27 0x03dd87d8 in GSEventRunModal ()
#28 0x03dd888a in GSEventRun ()
#29 0x00a7f626 in UIApplicationMain ()
#30 0x000025ed in main at /Users/jake/Documents/Avocado/AvocadoTest1.0/AvocadoTest1/main.m:16

如果我可以为您设置更好的格式,请告诉我。

最佳答案

当你运行类似的东西时:

[self dismissViewControllerAnimated:YES 
completion:^{
NSLog(@"Complete.");
}];

在一个 block 内并运行如下内容:

[self presentModalViewController:[paymentStack navigationController] animated:YES];

在 block 之外,不可能知道哪一行代码将首先运行。有时它会是dismissViewControllerAnimated:,有时它会是presentModalViewController:。

如果 dismissViewControllerAnimated: 首先运行,那么 viewController 可能会被释放,因此当应用程序尝试运行 PresentModalViewController: 时,它正在向不再存在的对象发送消息,这可能是崩溃的原因。

祝你好运!

关于iOS解雇ModalViewController导致EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9911026/

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