I am trying to create a custom UISlider. I need to insert subviews (like a label) to self. I'm using the
[self insertSubview:_label1 atIndex:2];
method to do so. Everything works fine when I create my slider in IB and assign my PWSlider class to it.
However, if I try to create my PWSlider from code, there are no subviews present when I do my inits (adding my subviews).
For the init in code I override initWithFrame
, for the NIB-case I tried both, awakeFromNib as well as initWithCoder - same result.
When I debug with
NSLog(@"subview count: %d", [self.subviews count]);
the result is that loaded from NIB I get 3 subviews, loaded programmatically I get 0.
Any ideas?