Undeclared Identifier after the void

£可爱£侵袭症+ 提交于 2019-12-12 10:28:02

问题


I have got this error on the line where the void is it says undeclared identifier for sliderDidChange can some one please help me with this i can;t find any answers.

h. file

//
//  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];
}

can someone please help quick


回答1:


Well the problem may be you added an { anywhere above that line of code

Please make sure all open braces are closed properly




回答2:


I assume 1) you have synthesized your properties in the .m file, 2) you have implemented all methods declared in the .h file also there, and 3) the 6 statements in your .m file with which you create your localslider object, i.e. those followed by -(void)sliderDidChange:(UISlider *)slider, are part of the viewDidLoad method.
In this case, you should only get a warning that the argument slider of your -(void)sliderDidChange:(UISlider *)slider method hides your instance variable with the same name in this method.



来源:https://stackoverflow.com/questions/15775857/undeclared-identifier-after-the-void

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!