ipad风景/人像图片

ipad风景/人像图片

问题描述:

我正在研究ipad应用程序开发(关于图像)的UI问题。我已经阅读了苹果发展网站上的一些文件,但我找不到任何有关它的信息。ipad风景/人像图片

是否存在图像文件的任何文件约定来区分系统应为横向/纵向加载哪个图像。因为我看到启动图像,我们可以使用“MyLaunchImage-Portrait.png”&“MyLaunchImage-Lanscape.png”。我曾尝试将“-Landscape”,“-Portrait”,“-Landscape〜ipad”,“-Portrait〜ipad”添加到其他通用的图像中,但失败。

以前有没有人遇到过这个问题?

不幸的是,除了iPad的启动图像以外,没有其他的标准约定。但是,您可以使用NSNotificationCenter来侦听方向更改事件并相应地响应它们。这里有一个例子:

- (void)awakeFromNib 
{ 
    //isShowingLandscapeView should be a BOOL declared in your header (.h) 
    isShowingLandscapeView = NO; 
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(orientationChanged:) 
               name:UIDeviceOrientationDidChangeNotification 
               object:nil]; 
} 

- (void)orientationChanged:(NSNotification *)notification 
{ 
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; 
    if (UIDeviceOrientationIsLandscape(deviceOrientation) && 
     !isShowingLandscapeView) 
    { 
     [myImageView setImage:[UIImage imageNamed:@"myLandscapeImage"]]; 
     isShowingLandscapeView = YES; 
    } 
    else if (UIDeviceOrientationIsPortrait(deviceOrientation) && 
      isShowingLandscapeView) 
    { 
     [myImageView setImage:[UIImage imageNamed:@"myPortraitImage"]]; 
     isShowingLandscapeView = NO; 
    } 
} 
+0

这是我使用的方式,不必使用通知中心来检测方向变化: - (无效)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation时间:(NSTimeInterval)持续时间{ } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { } – user1653545