I am working on a ViewController which switches view based on a UISegmentControl. I found a tutorial online after viewing this question on stack overflow
The main view controller is a tab view controller and then on one of the tabs there is a uinavigationcontroller which contains a segmented control (hope your still with me). The problem I am having is with the height of the view of the views in the segmented control. The first selected view is resized correctly but all other views within the segment control ignore the fact there is a tab bar there and there views go under the tab bar.
I have tried adding the following but it doesn't seem to help.
controller1.view.autoresizesSubviews = YES;
controller1.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
controller2.view.autoresizesSubviews = YES;
controller2.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Any ideas?
Another issue is with rotation. If I rotate when on the segmented view. The current selected view will rotate, if I change segment the view will have not rotated to landscape and will only take up a small proportion of the screen (as shown below).
I have overwrote all the rotation related methods in the SegmentedViewController and looped over the array of views it is managing and called there method. This doesn't seem to have done the job unfortunately.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
for (UIViewController * viewController in self.segmentedViewControllers)
[viewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
for (UIViewController * viewController in self.segmentedViewControllers)
[viewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
for (UIViewController * viewController in self.segmentedViewControllers)
[viewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
etc…