iPad加载视图和界面方向

时间:2012-04-18 19:35:39

标签: objective-c ios uiimageview splash landscape-portrait

我的应用有问题。我对UIImageView“Default-Landscape.png”感兴趣,代码是:

- (void)showLoadingWithTitle:(NSString*)loadingTitle {
    if(![self.view viewWithTag:123456]) {
        UIImageView *overlayView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
        //overlayView.backgroundColor = [UIColor lightGrayColor];
        overlayView.tag = 123456;
        overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth+UIViewAutoresizingFlexibleHeight;
        overlayView.image = [UIImage imageNamed:@"Default-Landscape.png"];
    }
}

到目前为止,这么好。当我将iPad旋转到Portrait时出现问题,我认为Portait正在加载Landscape图像,因为它看起来不应该,我不知道该怎么做......¿任何想法?

1 个答案:

答案 0 :(得分:0)

编辑:实际上更简单......

  - (void)showLoadingWithTitle:(NSString*)loadingTitle {
    if(![self.view viewWithTag:123456]) {
        UIImageView *overlayView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
        //overlayView.backgroundColor = [UIColor lightGrayColor];
        overlayView.tag = 123456;
        overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth+UIViewAutoresizingFlexibleHeight;
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) || 
            ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) 
         {
        overlayView.image = [UIImage imageNamed:@"Default-Landscape.png"];
         } else
{
        overlayView.image = [UIImage imageNamed:@"Default-Portrait.png"];

}
    }
}