gpt4 book ai didi

iphone - AVCaptureSession 之前应为 "("

转载 作者:行者123 更新时间:2023-12-03 21:09:21 25 4
gpt4 key购买 nike

当我尝试构建我的应用程序时,XCode 向我显示此错误

AVCaptureSession 之前应有“(”

有人可以帮我解决这个警告吗?这是我的代码:

ViewController.h

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface ViewController : UIViewController
{
}

- (IBAction)SwitchON_Flash;
- (void)setTorchSession:(AVCaptureSession *)CaptureSession;

@end

ViewController.m

#import "ViewController.h"

@implementation ViewController

UIAlertView *NoFlash;

- (IBAction)SwitchON_Flash
{
AVCaptureDevice *Device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

if ([Device hasTorch] && [Device hasFlash])
{
if (Device.torchMode == AVCaptureTorchModeOff)
{
AVCaptureDevice *Device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *FlashInput = [AVCaptureDeviceInput deviceInputWithDevice:device error: nil];
AVCaptureVideoDataOutput *VideoOutput = [[AVCaptureVideoDataOutput alloc] init];
AVCaptureSession *CaptureSession = [[AVCaptureSession alloc] init];
[CaptureSession beginConfiguration];
[CaptureSession addInput:FlashInput];
[CaptureSession addOutput:VideoOutput];
[CaptureSession commitConfiguration];
[CaptureSession startRunning];
[Device lockForConfiguration:nil];
[Device setTorchMode:AVCaptureTorchModeOn];
[Device setFlashMode:AVCaptureFlashModeOn];
[Device unlockForConfiguration];
[self setTorchSession:CaptureSession];
[CaptureSession release];
[VideoOutput release];
}

else
{
[torchSession stopRunning];
}

}

else
{
NoFlash = [[UIAlertView alloc] initWithTitle:@"Uh-Oh"
message:@"Your device doesn't have a flash camera"
delegate:nil
cancelButtonTitle:@"mhmm, OK"
otherButtonTitles:nil];
NoFlash.delegate = self;
[NoFlash show];
[NoFlash release];
}
}

- (void)setTorchSession:(AVCaptureSession *)CaptureSession <== /// ERROR HERE ///
{
}

谢谢!

最佳答案

UIViewController 默认情况下没有该方法。您没有该方法的实现,因此它会向您发出此警告。如果您尝试运行此代码 - 您将收到“未知选择器发送到实例”错误。

您必须在 View Controller 中为 torchSession 添加属性或实现该特定方法。

关于iphone - AVCaptureSession 之前应为 "(",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4237295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com