.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";
}
错误:
在类型为“ __strong id”的对象上找不到属性“值”
答案 0 :(得分:2)
id是任何对象,您需要使用控件名来标识对象,例如- (IBAction)slidersact:(UISlider *)sender
而不是- (IBAction)slidersact:(id)sender
- (IBAction)slidersact:(UISlider *)sender {
self.lbl2.text = [NSString stringWithFormat:@"%.0f", sender.value];
}