作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
Thread : Fatal Exception: NSRangeException
0 CoreFoundation 0x2ff42f03 __exceptionPreprocess + 130
1 libobjc.A.dylib 0x3a6d7ce7 objc_exception_throw + 38
2 CoreFoundation 0x2fed6eff -[__NSOrderedSetM objectAtIndex:] + 202
3 PhotosUI 0x369ab149 -[PUPhotosGridViewController assetAtIndexPath:]
4 PhotosUI 0x369b55b7 -[PUPhotosGridViewController collectionView:shouldSelectItemAtIndexPath:]
5 UIKit 0x3298e42b -[UICollectionView _selectItemAtIndexPath:animated:scrollPosition:notifyDelegate:] + 174
6 UIKit 0x3298e36f -[UICollectionView _userSelectItemAtIndexPath:] + 154
7 UIKit 0x3298e055 -[UICollectionView touchesEnded:withEvent:] + 380
8 UIKit 0x328f8f97 forwardTouchMethod + 234
9 UIKit 0x3276a541 _UIGestureRecognizerUpdate + 5528
10 UIKit 0x327a2325 -[UIWindow _sendGesturesForEvent:] + 772
11 UIKit 0x327a1c4b -[UIWindow sendEvent:] + 666
12 UIKit 0x32776e75 -[UIApplication sendEvent:] + 196
13 UIKit 0x32775541 _UIApplicationHandleEventQueue + 7120
14 CoreFoundation 0x2ff0dfe7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
15 CoreFoundation 0x2ff0d4af __CFRunLoopDoSources0 + 206
16 CoreFoundation 0x2ff0bc9f __CFRunLoopRun + 630
17 CoreFoundation 0x2fe767a9 CFRunLoopRunSpecific + 524
18 CoreFoundation 0x2fe7658b CFRunLoopRunInMode + 106
19 GraphicsServices 0x34de36d3 GSEventRunModal + 138
20 UIKit 0x327d5891 UIApplicationMain + 1136
有人知道这个错误吗?我只知道当您在 UIImagePickerController 中从相机胶卷中选择一张照片时会发生什么。
更新代码:
- (void)addPhotoFromSource:(UIImagePickerControllerSourceType)source {
if (![UIImagePickerController isSourceTypeAvailable:source])
return;
NSString* imageType = (__bridge NSString*)kUTTypeImage;
if (![[UIImagePickerController availableMediaTypesForSourceType:source] containsObject:imageType])
return;
self.pickerController = [[UIImagePickerController alloc] init];
self.pickerController.sourceType = source;
self.pickerController.mediaTypes = [NSArray arrayWithObject:imageType];
self.pickerController.delegate = self;
[self presentViewController:self.pickerController animated:YES completion:nil];
}
更新我的 didFinishPickingMediaWithInfo 方法:
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {
UIImage *imageOriginal = [info objectForKey:UIImagePickerControllerOriginalImage];
UIViewController* vc = [self.storyboard instantiateViewControllerWithIdentifier:@"Crop"];
vc.image = imageOriginal;
[picker pushViewController:vc animated:YES];
[picker setNavigationBarHidden:YES animated:YES];
}
我的 imagePickerControllerDidCancel 方法:
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
最佳答案
它在 ios 7.x 上重现。重现步骤:
为了解决这个问题,我订阅了通知 UIApplicationDidEnterBackgroundNotification 并删除了 UIImagePickerViewController。
if ([self _isIOS7])
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidEnterToBackgroundNotification:) name:UIApplicationDidEnterBackgroundNotification object:nil];
}
...
- (void)_applicationDidEnterToBackgroundNotification:(NSNotification*)notificaiton
{
if ([self.owner presentedViewController] != nil)
{
[self _dismissImagePicker:NO];
}
}
关于ios - -[PUPhotosGridViewController assetAtIndexPath :] NSRangeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22757611/
Thread : Fatal Exception: NSRangeException 0 CoreFoundation 0x2ff42f03 __exceptionP
我是一名优秀的程序员,十分优秀!