时间:2010-07-26 11:46:23

标签: iphone xcode view uiimageview rotation

1 个答案:

答案 0 :(得分:1)

如果您向视图添加子视图,则必须自行更改子视图的方向。只会为第一个viewcontroller调用willRotateToInterfaceOrientation,所以如果你将Subviews添加到viewcontroller,这可能是一种可接受的方式:

在ViewController中

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    for (int i = 0; i < [self.viewControllers count]; i++ ) {
        [[self.viewControllers objectAtIndex:i] didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    }
}
你在Subview ViewController中的

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
    [self adjustViewsForOrientation:self.interfaceOrientation];
}

    - (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation {
        if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
            NSLog(@"Subview Landscape");
            //Do Your Landscape Changes here
        }
        else if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
            NSLog(@"Subview Portrait");
            //Do Your Portrait Changes here
        }
    }

这可能会让你朝着正确的方向前进。