-1

在没有找到答案后,我不得不再次向大家寻求帮助。我正在以UIStepper编程方式创建一个,但它不会显示。标签、按钮和开关都显示正常,所以我一定遗漏了与步进器相关的东西。

在我的代码的其他地方,我声明并初始化UIView *vandNSMutableArray *steppers和声明UIStepper *st。创建步进器的代码是:

st = [[UIStepper alloc] init];
st.frame = CGRectMake(xnear, ypos, 0, 0);
[st addTarget:self action:@selector(stepper1:) forControlEvents:UIControlEventValueChanged];
[st setMinimumValue:0];
[st setMaximumValue:99];
[st setWraps:NO];
[st setContinuous:NO];
[v addSubview:st];
[steppers addObject:st];

在运行时xnear = 100ypos = 250,因此步进器在显示器内。正上方的标签和正下方的文本字段正在显示。关于宽度和高度状态的其他问题UIStepper被忽略了,所以我都使用了 0。这段代码有什么明显的问题吗?

4

2 回答 2

0

坦率地说,答案很尴尬。为 设置了自定义背景颜色,但UIView没有为控件设置颜色。我能够让步进器显示以下代码行:

st.backgroundColor = [UIColor whiteColor];

同样,UISegmentedControl *sc当我添加时出现了:

sc.backgroundColor = [UIColor whiteColor];

感谢您的帮助,很抱歉浪费您的时间!

于 2014-12-04T21:08:17.847 回答
0

您将 UIStepper 的高度和宽度设置为 0

st.frame = CGRectMake(xnear, ypos, 0, 0);

给出一些高度和宽度

st.frame = CGRectMake(xnear, ypos,200, 100);
于 2014-12-04T06:37:15.377 回答