2016-04-06 11 views
1

iOSでは、UIImagePickerControllerを使用してカメラビューを表示すると、アプリケーションがクラッシュします。これは、iOS 8,7、iPhone 5s、5cで発生します。 UIImagePickerControllerを使用してカメラビューを表示すると、iOSがクラッシュする

* thread #1: tid = 0x40a07, 0x0000000194bd40a8 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2 14.1 
frame #0: 0x0000000194bd40a8 libobjc.A.dylib`objc_exception_throw 
frame #1: 0x0000000182e3bb34 CoreFoundation`-[__NSArrayI objectAtIndex:] + 224 
frame #2: 0x00000001896dbf64 CameraKit`-[CAMFocusView _fadeOutIfNeeded] + 164 
frame #3: 0x00000001897394bc CameraKit`-[CAMPreviewView focusDidEnd] + 140 
frame #4: 0x00000001897006f4 CameraKit`-[CAMCameraView _updatePreviewForFocusDidEnd] + 44 
frame #5: 0x00000001897005b0 CameraKit`-[CAMCameraView cameraControllerFocusDidEnd:] + 32 
frame #6: 0x000000018974ed4c CameraKit`-[CAMCaptureController _focusCompleted] + 244 
frame #7: 0x0000000189751254 CameraKit`__71-[CAMCaptureController observeValueForKeyPath:ofObject:change:context:]_block_invoke + 956 
frame #8: 0x00000001897505e4 CameraKit`-[CAMCaptureController _runOnMainThreadImmediatelyIfPossibleWithBlock:] + 68 
frame #9: 0x0000000189750e48 CameraKit`-[CAMCaptureController observeValueForKeyPath:ofObject:change:context:] + 200 
frame #10: 0x0000000183da7218 Foundation`-[NSKeyValueObservance observeValueForKeyPath:ofObject:change:context:] + 468 
frame #11: 0x0000000183d815c4 Foundation`NSKeyValueNotifyObserver + 340 
frame #12: 0x0000000183d810e4 Foundation`NSKeyValueDidChange + 460 
frame #13: 0x0000000183d6a88c Foundation`-[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 116 
frame #14: 0x000000018179f1f4 AVFoundation`-[AVCaptureFigVideoDevice _handleNotification:payload:] + 900 
frame #15: 0x0000000182f1027c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20 
frame #16: 0x0000000182f0f384 CoreFoundation`__CFRunLoopDoBlocks + 312 
frame #17: 0x0000000182f0d9a8 CoreFoundation`__CFRunLoopRun + 1756 
frame #18: 0x0000000182e392d4 CoreFoundation`CFRunLoopRunSpecific + 396 
frame #19: 0x000000018c8976fc GraphicsServices`GSEventRunModal + 168 
frame #20: 0x0000000187a36f40 UIKit`UIApplicationMain + 1488 
frame #21: 0x000000010038452c beibei`main(argc=1, argv=0x000000016fd2b9d0) + 248 at main.m:29 
frame #22: 0x000000019527ea08 libdyld.dylib`start + 4 

このすべて

がシステム関数であり、最後の点は __NSArrayI objectAtIndex次のとおりです。ここで

UIImagePickerController *imagePickerC = [[UIImagePickerController alloc] init]; 
imagePickerC.sourceType = type; 
imagePickerC.delegate = self; 
imagePickerC.allowsEditing = NO; 
[self presentViewController:imagePickerC animated:YES completion:nil]; 

クラッシュスタックさ:

ここで私が使用したコードです。

+0

このコードを試してくださいUIImagePickerController * picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsEditing = YES; picker.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentViewController:ピッカーアニメーション:はい完了:NULL]; – iOS

+0

@DarjiJigarはそれを代わりに答えとして残していますか?説明のためのフォーマットとスペースを簡単にすることができます。 – Bloodied

+0

コメントをいただきありがとうございます。このコードを泣かせましたが、クラッシュしました。スタックは同じです – cpengu

答えて

0

私はカメラ画像を選んで持っており、ソースは私のためにその作業、以下のとおりである、

if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 

     UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error" 
                   message:@"Device has no camera" 
                  delegate:nil 
                cancelButtonTitle:@"OK" 
                otherButtonTitles: nil]; 

     [myAlertView show]; 

    } 
    else 
    { 
     UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init]; 
     photoPicker.delegate = self; 
     photoPicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
     photoPicker.mediaTypes = [NSArray arrayWithObjects: 
            (NSString *) kUTTypeImage, 
            nil]; 
     photoPicker.allowsEditing = YES; 
     [self presentViewController:photoPicker animated:YES completion:NULL]; 
    } 

し、またそのも私のために働いて、以下に示すのギャラリーコードから画像を取得

UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init]; 
    photoPicker.delegate = self; 
    photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

    [self presentViewController:photoPicker animated:YES completion:NULL]; 

枠組みAssetsLibrary(例 - #import <AssetsLibrary/AssetsLibrary.h>を)忘れないでください

はその有用ホープ..

+0

それはほとんどのiPhoneでうまく動作しますが、5秒、5秒、ios 8.4でクラッシュするので、私は混乱しています – cpengu

+0

iphone 5、 5cをチェックし、このコードが正常に動作する、私はあなたが混乱していると思います。 –

関連する問題