当我尝试以编程方式将 UISlider 添加到 UIView 时,如果宽度太高,它不会出现
我正在尝试以编程方式向 UIView 添加一个具有可变高度的垂直 UISlider。这就是我到目前为止所遇到的问题
int fullSize = [myBottle.barBottem intValue] - [myBottle.barTop intValue];
CGRect frame = CGRectMake(200, 150,fullSize, 23);
slider = [[UISlider alloc] initWithFrame:frame];
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
[slider setBackgroundColor:[UIColor clearColor]];
slider.minimumValue = 0.0;
slider.maximumValue = fullSize;
slider.continuous = YES;
slider.transform = CGAffineTransformMakeRotation(M_PI * -
0.5);;
[self.view addSubview:slider];
我的问题是,每当 fullSize > 时, 320,滑块不会出现。任何帮助将不胜感激!
I'm trying to programmatically add a vertical UISlider to a UIView, with a variable height. This is what I have so far
int fullSize = [myBottle.barBottem intValue] - [myBottle.barTop intValue];
CGRect frame = CGRectMake(200, 150,fullSize, 23);
slider = [[UISlider alloc] initWithFrame:frame];
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
[slider setBackgroundColor:[UIColor clearColor]];
slider.minimumValue = 0.0;
slider.maximumValue = fullSize;
slider.continuous = YES;
slider.transform = CGAffineTransformMakeRotation(M_PI * -
0.5);;
[self.view addSubview:slider];
My problem is that whenever fullSize is > 320, the slider wont appear. Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以试试这个
然后制作滑块值方法
-(void)slider:Action
You can try this
and make slider value method also
then -(void)slider:Action
UIScrollView 的框架不应大于包含 UIView 的矩形。您应该更改 UIScrollView 的 contentSize,而是设置其高度/宽度。
The UIScrollView's frame should not be bigger than the containing UIView's rect. You should be altering the UIScrollView's contentSize, setting its height/width instead.
试试这个代码:
1.创建一个新的滑块
2.对于滑块操作
Try this Code:
1.Create a new slider
2.For Slider Actions