0

我的应用程序有问题。我有一个 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 旋转到纵向时出现问题,我认为 Portait 正在加载横向图像,因为它看起来不像应该的那样,我不知道该怎么办...¿任何想法?

4

1 回答 1

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"];

}
    }
}
于 2012-04-18T21:16:57.993 回答