使用UIImagePickerController时,应用程序在启动时崩溃

时间:2014-03-27 19:19:46

标签: ios

这是我的代码:

ViewController.h

@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

@property (retain, nonatomic) IBOutlet UITextView *messageText;
@property (retain, nonatomic) IBOutlet UIImageView *imageView;

-(IBAction)selectPhoto:(UIButton*)sender;

@end

ViewController.m

-(IBAction)selectPhoto:(UIButton *)sender
{
    /*
    UIImagePickerController* picker = [UIImagePickerController new];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:picker animated:YES completion:NULL];
     */
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    //UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    //self.imageView.image = chosenImage;

    //[picker dismissViewControllerAnimated:YES completion:NULL];
}


- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

    //[picker dismissViewControllerAnimated:YES completion:NULL];
}

目前所有代码都已注释掉,但应用仍然崩溃。如果我删除了UIImagePickerController的两个代理,那么应用程序就不会崩溃了。

这是一次崩溃的屏幕截图:

enter image description here

编辑:堆栈跟踪:

* thread #3: tid = 0x1214f, 0x000000010210efcb libobjc.A.dylib`objc_msgSend + 11, queue = 'NSOperationQueue 0x10bb50dd0', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
  * frame #0: 0x000000010210efcb libobjc.A.dylib`objc_msgSend + 11
    frame #1: 0x0000000101cce137 Foundation`_NSDescriptionWithLocaleFunc + 41
    frame #2: 0x0000000102321244 CoreFoundation`__CFStringAppendFormatCore + 7252
    frame #3: 0x000000010235f913 CoreFoundation`_CFStringCreateWithFormatAndArgumentsAux + 115
    frame #4: 0x00000001023bfa5b CoreFoundation`_CFLogvEx + 123
    frame #5: 0x0000000101cfe276 Foundation`NSLogv + 79
    frame #6: 0x0000000101cfe20a Foundation`NSLog + 148
    frame #7: 0x0000000100057726 SocialApp`__28-[GPPSignIn checkSDKVersion]_block_invoke + 439
    frame #8: 0x000000010006dfd4 SocialApp`-[GTMHTTPFetcher connectionDidFinishLoading:] + 714
    frame #9: 0x0000000101dec36b Foundation`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 48
    frame #10: 0x0000000101d2363b Foundation`-[NSBlockOperation main] + 75
    frame #11: 0x0000000101d71d34 Foundation`-[__NSOperationInternal _start:] + 623
    frame #12: 0x0000000101d73c0b Foundation`__NSOQSchedule_f + 64
    frame #13: 0x0000000102aa172d libdispatch.dylib`_dispatch_client_callout + 8
    frame #14: 0x0000000102a8feab libdispatch.dylib`_dispatch_async_redirect_invoke + 174
    frame #15: 0x0000000102aa172d libdispatch.dylib`_dispatch_client_callout + 8
    frame #16: 0x0000000102a91b27 libdispatch.dylib`_dispatch_root_queue_drain + 380
    frame #17: 0x0000000102a91d12 libdispatch.dylib`_dispatch_worker_thread2 + 40
    frame #18: 0x0000000102deeef8 libsystem_pthread.dylib`_pthread_wqthread + 314

1 个答案:

答案 0 :(得分:1)

正如您在回溯中看到的那样,它是与谷歌+ SDK相关的错误:

frame #7: 0x0000000100057726 SocialApp`__28-[GPPSignIn checkSDKVersion]_block_invoke + 439

使用SDK 1.5.0版本时出现完全相同的错误。谷歌刚刚发布了修复该崩溃的v1.5.1。