xcode小问题
发布网友
发布时间:2024-10-07 14:24
我来回答
共1个回答
热心网友
时间:2024-10-07 16:53
- (void)viewDidLoad
{
[superviewDidLoad];
UISlider* slider = [[UISlideralloc] initWithFrame: CGRectMake(self.view.center.x - 100, 10, 200, 100)];
slider.maximumValue=100;
slider.minimumValue=0;
[slider addTarget:selfaction:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
[self.viewaddSubview:slider];
UITextField* text = [[UITextFieldalloc]initWithFrame:CGRectMake(self.view.center.x -80, self.view.center.y - 100, 200, 100)];
text.text = [NSStringstringWithFormat: @"%lf", slider.value];
[self.viewaddSubview:text];
self.text = text;
}
- (void)sliderValueChanged:(UISlider*)s{
[self.textsetText:[NSString stringWithFormat: @"%lf", s.value]];
}