gpt4 book ai didi

ios - -[PUPhotosGridViewController assetAtIndexPath :] NSRangeException

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:18:29 25 4
gpt4 key购买 nike

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 上重现。重现步骤:

  1. 在应用程序中打开图像选择器。
  2. 打开“相机胶卷”。
  3. 按下主页按钮(您不应终止应用程序)。
  4. 转到“照片”。
  5. 删除最后一张照片。
  6. 打开应用程序。

为了解决这个问题,我订阅了通知 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com