I’m looking at an iPhone application, with several ViewControllers controlled by a UINavigationController.
Somewhere deep down one of the ViewControllers is creating a view, and the view is trying to pop a
UISegmentedControl *segmentedControl
up on top of itself like so:
[self.window addSubview:segmentedControl];
“self” is a specialized form of UIView, and the control’s frame is set
segmentedControl.frame = someFrame;
For some reason, the control is not showing up on top of the current view. Should this work, and, if it should, what are the most likely causes of trouble?
When you say
selfis a specialized form of UIView I’m guessing you are referring to a UIView custom subclass.If you are adding the UISegmentedControl from within this view, you want to do the following:
You set it’s frame relative to it’s superview, so if you want it on the top left corner you would do: