使用UIImagePickerController访问相册时,应用程序崩溃

时间:2012-04-07 15:11:13

标签: objective-c ios cocoa-touch uiimagepickercontroller

iTunes Connect有我的应用程序的崩溃报告。它说当我使用UIImagePickerController访问相册时应用程序会崩溃,但我无法在模拟器或真机上重现问题。以下是崩溃报告的内容。请帮我查明问题。

Hardware Model:      iPhone4,1
Process:         eyerecolor [5011]
Path:            /var/mobile/Applications/B9D7CEA3-DB1D-4CE3-B605-90EC066B7C92/eyerecolor.app/eyerecolor
Identifier:      eyerecolor
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]


Date/Time:       2012-04-06 18:51:37.692 -0500
OS Version:      iPhone OS 5.0 (9A334)
Report Version:  104


Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0


Last Exception Backtrace:
0   CoreFoundation                 0x371198bf __exceptionPreprocess + 163

1   libobjc.A.dylib                0x324891e5 objc_exception_throw + 33

2   CoreData                       0x3728c64b -[NSPersistentStoreCoordinator setMetadata:forPersistentStore:] + 411

3   PhotoLibraryServices           0x31585ffd +[PLManagedObjectContext(Private) recordVersion:forStore:] + 393

4   PhotoLibraryServices           0x31586385 +[PLManagedObjectContext(Private) configurePersistentStoreCoordinator:] + 897

5   PhotoLibraryServices           0x3158691f __69+[PLManagedObjectContext(Protected) sharedPersistentStoreCoordinator]_block_invoke_0323 + 179

6   libdispatch.dylib              0x32a908cf _dispatch_barrier_sync_f_invoke + 27

7   libdispatch.dylib              0x32a9072f dispatch_barrier_sync_f$VARIANT$mp + 63

8   libdispatch.dylib              0x32a9034f dispatch_sync_f$VARIANT$mp + 19

9   libdispatch.dylib              0x32a909f9 dispatch_sync$VARIANT$mp + 33

10  PhotoLibraryServices           0x3158681f +[PLManagedObjectContext(Protected) sharedPersistentStoreCoordinator] + 155

11  PhotoLibraryServices           0x315853c9 -[PLManagedObjectContext initWithConcurrencyType:useSharedPersistentStoreCoordinator:] + 121

12  PhotoLibraryServices           0x315852a7 +[PLManagedObjectContext contextForPhotoLibrary:] + 115

13  PhotoLibraryServices           0x31584ec9 -[PLPhotoLibrary(Protected) loadDatabase] + 237

14  PhotoLibraryServices           0x3154d87d -[PLPhotoLibrary initWithPath:canTriggerDatabaseUpdate:] + 305

15  PhotoLibraryServices           0x315942a1 __42+[PLSharedPhotoLibrary sharedPhotoLibrary]_block_invoke_0 + 61

16  libdispatch.dylib              0x32a92683 dispatch_once_f$VARIANT$mp + 47

17  PhotoLibraryServices           0x3159425f +[PLSharedPhotoLibrary sharedPhotoLibrary] + 83

18  PhotoLibrary                   0x32c69bc9 -[PLUILibraryViewController _updateFilteredAlbumListWithFilter:] + 157

19  PhotoLibrary                   0x32c6961b -[PLUILibraryViewController init] + 67

20  UIKit                          0x31f58cc5 -[UIImagePickerController _createInitialController] + 317

21  UIKit                          0x31f58d05 -[UIImagePickerController _setupControllersForCurrentSourceType] + 25

22  UIKit                          0x31f58711 -[UIImagePickerController viewWillAppear:] + 69

23  UIKit                          0x31d336b5 -[UIViewController _setViewAppearState:isAnimating:] + 145

24  UIKit                          0x31d8e61b -[UIViewController beginAppearanceTransition:animated:] + 191

25  UIKit                          0x31dd4691 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 4077

26  UIKit                          0x31dd314f -[UIViewController presentViewController:withTransition:completion:] + 3123

27  UIKit                          0x044f2e93 -[UIViewControllerAccessibility(SafeCategory) presentViewController:animated:completion:] + 51

28  UIKit                          0x31e2dd97 -[UIViewController presentModalViewController:animated:] + 31

29  eyerecolor                     0x00009c39 -[eyerecolorViewController showImagePicker:] (eyerecolorViewController.m:1855)

- (void)showImagePicker:(UIImagePickerControllerSourceType)sourceType
{
    if ([UIImagePickerController isSourceTypeAvailable:sourceType]) {
        self.m_pickerView.sourceType = sourceType;
        self.m_pickerView.allowsEditing = NO;
        [self presentModalViewController:self.m_pickerView animated:YES];
    }
}

- (void)viewDidLoad
{
    if (self.m_pickerView == nil) {
        self.m_pickerView = [[[UIImagePickerController alloc] init] autorelease];
        self.m_pickerView.delegate = self;
        self.m_pickerView.allowsImageEditing = NO;
    }
}

2 个答案:

答案 0 :(得分:0)

我不确定这是否能解决您的问题,但希望它会有所帮助...

您是否在iOS 5上尝试过代码?你的设备怎么样?

查看崩溃报告,您的问题似乎与iPhone 4S上的iOS 5有关:

Hardware Model: iPhone4,1
...
OS Version: iPhone OS 5.0 (9A334)

尽量不要自动发布您的UIImagePickerController。有时,自动释放的对象会产生问题而不是平滑内存管理。

编辑:还有一件事......这就是Apple建议实施UIImagePickerController的方式:

  1. 验证设备是否能够从中挑选内容 期望的来源。这样做是调用isSourceTypeAvailable:类 方法,提供一个常数 “UIImagePickerControllerSourceType”枚举。
  2. 检查您所使用的源类型可用的媒体类型 通过调用availableMediaTypesForSourceType:class来使用 方法。这使您可以区分可以使用的相机 视频录制和仅可用于静止图像的视频。
  3. 告诉图像选择器控制器根据调整UI 您想要提供的媒体类型 - 静止图像,电影或 两者 - 通过设置mediaTypes属性。
  4. 通过调用显示用户界面 presentViewController:animated:<完成:当前的方法 活动视图控制器,传递您配置的图像选择器 控制器作为新的视图控制器。在iPad上,呈现用户 使用popover的界面。这样做仅在sourceType时有效 图像选择器控制器的属性设置为 UIImagePickerControllerSourceTypeCamera。使用弹出窗口 控制器,使用“演示和解除”中描述的方法 Popover“在UIPopoverController类参考。
  5. 当用户点击按钮以选择新拍摄或保存的图像时 或电影,或取消操作,使用取消图像选择器 你的委托对象。对于新捕获的媒体,您的代表可以 然后将其保存到设备上的相机胶卷。对于以前保存过的 媒体,您的代表然后可以根据使用图像数据 你应用的目的。
  6. 来自UIImagePickerController Class Reference

    编辑(再次):嗯,如果你的设备上没有任何问题,那就很奇怪了,但我再次尝试建议一种改变实际情况的方法。

    在showImagePicker中实现您的UIImagePicker控制器:(UIImagePickerControllerSourceType)sourceType而不是viewDidLoad。

    使用allowEditing而不是allowsImageEditing(在iOS 3.1中已弃用)并且不自动释放您的对象...

答案 1 :(得分:0)

好的,这是我想到的一些事情。我希望它会起作用......

首先检查你是否在你的Controller的.h文件中包含UIImagePickerDelegate。其次有像didFinshPickingImage这样的委托方法尝试搜索Beppe给你的Class Reference。

如果这些东西没有用,请告诉我你的应用程序是否给出了Sigbrt或Bad Excess ......根据我的经验,我相信这将是一个sigbrt。 如果我没有错,你的应用程序将把你带到main.m文件。当然,你不能告诉什么是错误,所以在你的应用程序中添加一个EXCEPTION BREAK POINT。这将给你你的应用程序崩溃的确切点。

搜索那一点。我真正的问题是你的委托方法不起作用。

如果是最糟糕的情况,你仍然没有找到解决方案,最后一个度假村是THIS

让我知道它是否有效:) 干杯