无效后的未申报标识符

时间:2013-04-02 22:52:05

标签: xcode void identifier

我在行的地方出现了这个错误,说明了对于sliderDidChange的未声明的标识符,有些人可以帮助我,我可以找到任何答案。

小时。文件

//
//  LightViewController.h
//  Flash Light
//
//  Created by John Whitney on 12-07-27.
//  Copyright (c) 2012 Perfect Programs. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface LightViewController : UIViewController {
IBOutlet UISlider *slider;
IBOutlet UISlider *theslider;
IBOutlet UISlider *customslider;
UIButton *onButton;
UIButton *offButton;
UIImageView *onView;
UIImageView *offView;
}

@property(nonatomic, strong) IBOutlet UIButton *onButton;
@property(nonatomic, strong) IBOutlet UIButton *offButton;
@property(nonatomic, strong) IBOutlet UIImageView *onView;
@property(nonatomic, strong) IBOutlet UIImageView *offView;
@property(nonatomic, readonly) float torchLevel;

-(void)sliderDidChange:(UISlider *)slider;
-(BOOL)setTorchModeOnWithLevel:(float)torchLevel error:(NSError **)outError;
-(BOOL)supportsAVCaptureSessionPreset:(NSString *)preset;
-(IBAction)torchOn:(id)sender;
-(IBAction)torchOff:(id)sender;
@end

m.file

UISlider *localslider = [[UISlider alloc] initWithFrame:CGRectMake(20.0f, 20.0f, 280.0f, 40.0f)];
localslider.maximumValue = 1.0f;
localslider.minimumValue = 0.0f;
[localslider setContinuous:YES];
[localslider addTarget:self action:@selector(sliderDidChange:)  forControlEvents:UIControlEventValueChanged];
[self.view addSubview:localslider];


-(void)sliderDidChange:(UISlider *)slider
{

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[device lockForConfiguration:nil];
[device setTorchModeOnWithLevel:slider.value error:NULL];
[device unlockForConfiguration];
}

有人可以请快速帮助

2 个答案:

答案 0 :(得分:0)

问题可能是您在该行代码

之上的任何位置添加了{

请确保所有打开的支架都正确关闭

答案 1 :(得分:0)

我假设1)您已经在.m文件中合成了属性,2)您已经实现了.h文件中声明的所有方法,以及3)您创建的.m文件中的6个语句localslider对象,即后跟-(void)sliderDidChange:(UISlider *)slider的对象,是viewDidLoad方法的一部分 在这种情况下,您应该只收到一个警告,即slider方法的参数-(void)sliderDidChange:(UISlider *)slider会在此方法中隐藏具有相同名称的实例变量。