我想按顺序显示多个模态视图(例如,从图像选择器中选择图片后显示确认页面)。我的问题是,立即解雇和在随后的步骤中呈现的动画总是会以EXC_BAD_ACCESS
崩溃应用程序。多模态视图转换崩溃应用程序
我假设问题是CoreAnimation
没有区分这两个转换并且无法正确检测到第一个是否已经结束。
到目前为止,我的工作是引入一段似乎解决问题的延迟。不过,我认为这会使代码有点脆弱。是否有另一种解决方法?
这是一个UIKit中的错误,我应该提交一个错误报告吗?
示例代码
这里是重现崩溃一个简单的例子:
下面的类作为主控制器的实现创建一个新的基于视图的项目
当呈现图像选择器视图时点击'取消'
预期行为:由于后续调用viewDidAppear
,拾取器视图被解散并再次呈现。
实际行为:它与下面呈现的堆栈跟踪崩溃。
代码:
#import "SampleViewController.h"
@implementation SampleViewController
- (void)showModal {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
[self presentModalViewController:picker animated:YES];
// [picker release];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self showModal]; // this line crashes the app
// the following works as desired
// [self performSelector:@selector(showModal) withObject:nil afterDelay:1];
}
@end
崩溃堆栈跟踪:
#0 0x30b43212 in -[UIWindowController transitionViewDidComplete:fromView:toView:] #1 0x3095828e in -[UITransitionView notifyDidCompleteTransition:] #2 0x3091af0d in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] #3 0x3091ad7c in -[UIViewAnimationState animationDidStop:finished:] #4 0x00b54331 in run_animation_callbacks #5 0x00b54109 in CA::timer_callback #6 0x302454a0 in CFRunLoopRunSpecific #7 0x30244628 in CFRunLoopRunInMode #8 0x32044c31 in GSEventRunModal #9 0x32044cf6 in GSEventRun #10 0x309021ee in UIApplicationMain #11 0x00002794 in main at main.m:14
使用0.0作为延迟解决了问题!谢谢! – notnoop 2009-07-23 16:58:44