标签: uiimagepickercontroller

为什么这段代码有时会起作用,而不是其他代码?

我在我的应用程序中创建了一个"镜像"视图,它使用前置摄像头向用户显示"镜像".我遇到的问题是我几周没有触及这个代码(当时它确实有效)但是现在我再次测试它并且它不起作用.代码与以前相同,没有错误出现,故事板中的视图与之前完全相同.我不知道发生了什么,所以我希望这个网站会有所帮助.

这是我的代码:

if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) {
        //If the front camera is available, show the camera


        AVCaptureSession *session = [[AVCaptureSession alloc] init];
        AVCaptureOutput *output = [[AVCaptureStillImageOutput alloc] init];
        [session addOutput:output];

        //Setup camera input
        NSArray *possibleDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
        //You could check for front or back camera here, but for simplicity just grab the first device
        AVCaptureDevice *device = [possibleDevices objectAtIndex:1];
        NSError *error = nil;
        // create an input and add it to the session
        AVCaptureDeviceInput* input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; //Handle errors …
Run Code Online (Sandbox Code Playgroud)

camera objective-c uiimagepickercontroller avcapturesession

-1
推荐指数
1
解决办法
457
查看次数

How to convert 'UIImagePickerController.InfoKey.originalImage' into 'UIImage'

I'm developping an iOS phone app and I want to take a picture and store it in the app.

I am able to take the picture using a UIImagePickerController but I can't store it in my database. I'm using CoreData to store data in this app but for the picture, it seems that it is easier to store the picture in a folder and store the file path in Coredata. The issue is that I can get the picture i've …

uiimagepickercontroller uiimage swift

-1
推荐指数
1
解决办法
2740
查看次数

|| (OR)在具有两个可能的NSString对象的IF语句中不起作用

我有一个照片应用程序,让用户可以拍摄照片或视频,然后如果他们点击"使用照片"或"使用视频"按钮(取决于他们捕获的媒体类型),它会将照片或视频保存到相机胶卷.

这一切都适合拍照,我最初只设置应用程序拍照,但现在我添加了视频,我遇到了问题.我在我的应用程序中设置了一个if语句,用于kUTTypeimage或kUTTypeMovie,但它不喜欢我使用"||" 在我的if语句中用于"或".

它给出了"不兼容的整数到指针转换发送'int'到'NSString*'类型的参数的错误

我不明白为什么它会给我这个错误以及它为什么不让我使用|| 在我的if语句中用于"或".

这是我的ViewController.m文件中的代码块:

- (void)imagePickerController:pickerController didFinishPickingMediaWithInfo:(NSDictionary     *)info
{

NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

if ([mediaType isEqualToString:(NSString *)kUTTypeImage || (NSString *)kUTTypeMovie])
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

    UIImageWriteToSavedPhotosAlbum(image,nil,nil,nil);
}

[pickerController dismissModalViewControllerAnimated:YES];

}
Run Code Online (Sandbox Code Playgroud)

iphone if-statement objective-c uiimagepickercontroller ios

-4
推荐指数
1
解决办法
175
查看次数

iphone sdk如何从相机拍照并在同一视图中显示图像?

我将创建一个按钮和imageview.我将创建IBAction按钮打开UIImagepicker拍照.我需要之后图像需要在imageview中显示.如何得到这个.任何人都可以帮助我.

iphone objective-c uiimagepickercontroller ios4

-5
推荐指数
1
解决办法
9171
查看次数