exc_bad_access 与 UIImagePickerController 和 UIPopoverController
在我的应用程序(Ipad)中调用这段代码后,我得到了 EXC_BAD_ACCESS
我几乎没有从 XCode 中得到任何用于调试的信息,XCode 向我指出了这行代码:
int retVal = UIApplicationMain(argc, argv, nil, nil);
我猜一个对象已经过早自动释放了,但是为什么以及如何解决这个问题?
NSLog(@"OpenPhotoDialog");
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = srcType;
UIDevice* thisDevice = [UIDevice currentDevice];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker] ;
popover.delegate = self;
[popover presentPopoverFromRect:self.view.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
I get a EXC_BAD_ACCESS right after calling this piece of code in my app (Ipad)
I get almost nothing from XCode for debugging, XCode points me that line of code:
int retVal = UIApplicationMain(argc, argv, nil, nil);
I guess an object has been autoreleased too early but why and how to fix this?
NSLog(@"OpenPhotoDialog");
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = srcType;
UIDevice* thisDevice = [UIDevice currentDevice];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker] ;
popover.delegate = self;
[popover presentPopoverFromRect:self.view.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常 EXC_BAD_ACCESS 会发送对象到已释放的块。
如果您将可执行文件中的参数设置
为 NSZombieEnabled YES
那么您可以知道哪个对象正在取消分配哪个对象已不再使用。
干杯
Usually EXC_BAD_ACCESS Will Come Sending Object To the Deallocated Blocks.
if you set The Argument in Executables
NSZombieEnabled YES
Then you Can Know Which Object is De allocating Which is So longer Used.
cheers