UISlider error : Property 'value' not found on object of type '__strong id'
UISlider error : Property 'value' not found on object of type '__strong id'
.h 文件:
@property (strong, nonatomic) IBOutlet UISlider *sliderr;
@property (strong, nonatomic) IBOutlet UILabel *lbl2;
.m 文件:
- (IBAction)slidersact:(id)sender {
self.lbl2.text = [NSString stringWithFormat:@"%.0f", sender.value];
[error with ^^]
}
- (void)viewDidLoad {
[super viewDidLoad];
self.sliderr.minimumValue = 0.0f;
self.sliderr.maximumValue = 100.0f;
self.lbl2.text = @"0";
}
错误:
Property 'value' not found on object of type '__strong id'
id 是任何对象,您需要使用您的控件名称来标识您的对象,例如 - (IBAction)slidersact:(UISlider *)sender
而不是 - (IBAction)slidersact:(id)sender
- (IBAction)slidersact:(UISlider *)sender {
self.lbl2.text = [NSString stringWithFormat:@"%.0f", sender.value];
}
.h 文件:
@property (strong, nonatomic) IBOutlet UISlider *sliderr;
@property (strong, nonatomic) IBOutlet UILabel *lbl2;
.m 文件:
- (IBAction)slidersact:(id)sender {
self.lbl2.text = [NSString stringWithFormat:@"%.0f", sender.value];
[error with ^^]
}
- (void)viewDidLoad {
[super viewDidLoad];
self.sliderr.minimumValue = 0.0f;
self.sliderr.maximumValue = 100.0f;
self.lbl2.text = @"0";
}
错误:
Property 'value' not found on object of type '__strong id'
id 是任何对象,您需要使用您的控件名称来标识您的对象,例如 - (IBAction)slidersact:(UISlider *)sender
而不是 - (IBAction)slidersact:(id)sender
- (IBAction)slidersact:(UISlider *)sender {
self.lbl2.text = [NSString stringWithFormat:@"%.0f", sender.value];
}