繁体   English   中英

ios6中的UIImagePickerController追赶

[英]UIImagePickerController chashes in ios6

当我在ios 6中触摸我的拍照按钮时,我的应用程序崩溃了,我真的不知道如何解决它...(im 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

抱歉,如果我太无法处理:)如果有人可以阅读我的代码,并解决我的小问题...我将是世界上最幸福的人...

马蒂斯

编辑:我不知道我是否发现错误,但是这出现了:

2013-02-22 16:35:09.886 Harold [81732:c07] *由于未捕获的异常“ NSGenericException”而终止应用程序,原因:“仅当源控制器由UINavigationController的实例管理时才能使用推送选择。” *第一掷调用堆栈:(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:终止叫做抛出异常(LLDB)

尝试按下面的按钮操作并检查:

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

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.delegate = self;

[self presentViewController:imagePicker animated:YES completion:nil];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM