【发布时间】:2014-03-27 19:19:45
【问题描述】:
这是我的代码:
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 的两个代表,则应用程序不会再崩溃。
这是崩溃的屏幕截图:
编辑:堆栈跟踪:
* 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
【问题讨论】:
-
console有错误吗?
-
没有错误,这就是为什么我无法弄清楚问题所在。
-
你的主线程发生了什么?你在
NSOperationQueue中运行任何东西吗?看起来任何试图在那里运行的东西都试图访问不再存在的东西(即已发布)。 -
我刚刚意识到我从支持文件中删除了一张图片,但我不再使用它了。现在我回滚到我之前的提交,在添加 PickerController 之前,给我一个关于丢失图片的构建错误:PBXCp 错误(图片现在在支持文件中显示为红色)。于是我把图片删了,现在每次都崩溃了。这可能是问题所在?
-
你能把代码贴在你显示视图/图像选择器的地方吗?模拟器不支持相机模式,如果您尝试在该模式下推送图像选择器,则会导致崩溃。话虽这么说,它通常会告诉您为什么它会崩溃并且不是那么模棱两可。显示扩展的回溯也会有所帮助。
标签: ios