开发者

UITableViewCell with two subviews, second added subview position and size isn't shown as inited

I got a UITableViewCell and added a UISlider and a UILabel to show the value of the slider should look like this: |Bezeichnung|Value von UISlider| UISlider|

Here is my code in cellForRowAtIndexPath

开发者_StackOverflow中文版
if (self.maxValue == nil) {
   self.maxValue = [[UISlider alloc] initWithFrame:CGRectMake(130.0, 6.0, 140.0, 30.0)];
   self.maxValue.minimumValue = [self.selectedControl.minValue floatValue]; 
   self.maxValue.maximumValue = 1.0;
}
self.maxValue.value = [self.selectedControl.maxValue floatValue];

//Init UILabel
if (self.maxLabel == nil) {
   self.maxLabel = [[UILabel alloc] initWithFrame:CGRectMake(100., 6., 100., 30.)];}
   self.maxLabel.text = [NSString stringWithFormat:@"%.2f", [self.selectedControl.maxValue      floatValue]];
}
cell.textLabel.text = @"Max. Value";

//Add UILabel and UISlider
[cell.contentView addSubview:self.maxLabel];
[cell.contentView addSubview:self.maxValue];

and the result is

IMG LINK (sorry i'm unable to post images)

the position of the UILabel is correct, but the position and size of the UISlider is ignored. If i change the order of the addSubview commands, always the second added view is wrong.

What is wrong? and thanks for your HELP

best regards


Found the problem.
I had the two UISliders as IBOutlets in the IB to add the deligates.
That seems to be the problem, now i removed the outlets and coded the deligates myself.
And it just works :)

Thanks for your believes in me!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜