1

iOS 6で写真を撮るボタンをタッチするとアプリがクラッシュし、修正方法が本当にわかりません...(私はn00bです):)

私のコード Buttons.h を見てください:

 @interface Buttons : UIViewController
    <UIImagePickerControllerDelegate,
    UINavigationControllerDelegate>

    @property BOOL newMedia;
    @property (strong, nonatomic) IBOutlet UIImageView *imageView;
    - (IBAction)useCamera:(id)sender;
    - (IBAction)useCameraRoll:(id)sender;
    @end

Buttons.m :

#import "Buttons.h"




 @implementation Buttons

    - (void) useCamera:(id)sender
    {
        if ([UIImagePickerController isSourceTypeAvailable:
             UIImagePickerControllerSourceTypeCamera])
        {
            UIImagePickerController *imagePicker =
            [[UIImagePickerController alloc] init];
            imagePicker.delegate = self;
            imagePicker.sourceType =
            UIImagePickerControllerSourceTypeCamera;
            imagePicker.mediaTypes = @[(NSString *) kUTTypeImage];
            imagePicker.allowsEditing = NO;
            [self presentViewController:imagePicker
                               animated:YES completion:nil];

        }
    }
    #pragma mark -
    #pragma mark UIImagePickerControllerDelegate

    -(void)imagePickerController:(UIImagePickerController *)picker
    didFinishPickingMediaWithInfo:(NSDictionary *)info
    {


        [self dismissViewControllerAnimated:YES completion:nil];




    }

    -(void)image:(UIImage *)image
    finishedSavingWithError:(NSError *)error
     contextInfo:(void *)contextInfo
    {
        if (error) {
            UIAlertView *alert = [[UIAlertView alloc]
                                  initWithTitle: @"Save failed"
                                  message: @"Failed to save image"
                                  delegate: nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
            [alert show];
        }
    }
    -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
    {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    @end

    @implementation UIImagePickerController (NonRotating)

    - (BOOL)shouldAutorotate
    {
        return NO;
    }

    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationMaskPortrait;
    }

    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskAll;
    }
    @end

私が処理するにはあまりにもn00bである場合は申し訳ありません:)誰かが私のコードを読んで、私の小さな問題を修正できたら...私は世界で最も幸せな男になるでしょう...

マティス

編集:エラーが見つかったかどうかはわかりませんが、これが発生しました:

2013-02-22 16:35:09.886 Harold[81732:c07] * キャッチされない例外 'NSGenericException' によるアプリの終了、理由: 'プッシュ セグエは、ソース コントローラーが UINavigationController のインスタンスによって管理されている場合にのみ使用できます。* First throw call stack: (0x1e1a012 0x13bae7e 0x754f31 0x746b99 0x746c14 0x13ce705 0x3022c0 0x302258 0x3c3021 0x3c357f 0x3c26e8 0x331cef 0x331f02 0x30fd4a 0x301698 0x2053df9 0x2053ad0 0x1d8fbf5 0x1d8f962 0x1dc0bb6 0x1dbff44 0x1dbfe1b 0x20527e3 0x2052668 0x2feffc 0x2c3d 0x2b65) libc++abi.dylib: terminate called throwing an exception (lldb)

4

1 に答える 1

0

ボタンのアクションとチェックで以下のように試してください:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.delegate = self;

[self presentViewController:imagePicker animated:YES completion:nil];
于 2013-02-23T05:13:33.910 に答える