2014-03-31 1 views
3
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의 카메라 롤에서 사진을 선택하면 어떻게되는지 알 수 있습니다.- [PUPhotGridViewController assetAtIndexPath :] NSRangeException

업데이트 코드 :

- (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]; 
} 
+0

didfinishPicking 코드를 입력하십시오. – iPatel

+0

내 충돌 로그에서 같은 문제가 나타납니다. 그것을 재현 할 수 있습니까? 어떤 상황에서? –

답변

1

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]; 
    } 
} 
관련 문제