【发布时间】:2011-10-13 03:45:08
【问题描述】:
我为此苦苦挣扎了一段时间,但找不到任何有相关问题的人。 我的问题是在 iPad 上为横向模式加载的背景图像不是正确的(它加载图像的纵向版本)。 在 iphone 或 iPod 上它可以正常工作。
我在 AppDelegate 文件中使用的代码如下:
if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0 ) {
// Create resizable images
UIImage *gradientImageP = [[UIImage imageNamed:@"header"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
UIImage *gradientImageL = [[UIImage imageNamed:@"header-Landscape"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:gradientImageP
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:gradientImageL
forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];
[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:0 green: 0 blue:0 alpha:1]];
}
问题出在这一行?
[[UINavigationBar appearance] setBackgroundImage:gradientImageL
forBarMetrics:UIBarMetricsLandscapePhone];
我的图片名称如下:
- header-Landscape~iphone.png
- header-Landscape@2x~iphone.png
- header-Landscape~ipad.png
- header~iphone.png
- header@2x~iphone.png
- 标题~ipad
编辑:导航栏问题截图:
- iPhone 肖像: http://imageshack.us/photo/my-images/200/iphoneportrait.png/
- iPhone 横向: http://imageshack.us/photo/my-images/193/iphonelandscape.png/
- iPad 肖像: http://imageshack.us/photo/my-images/62/ipadportrait.png/
- iPad 横向: http://imageshack.us/photo/my-images/200/ipadlandscape.png/
有人遇到这个问题吗? 我对如何解决这个问题持开放态度,tkz
【问题讨论】:
-
您是否希望将 ~ipad 加载到 iPad 上?我以前没见过这个大会。你有一些自动为你做的代码吗?
-
是的,我希望将带有 ~ipad 的文件名加载到该设备上。我在应用程序的其他图像上使用这种名称并且它们正确加载。无论如何,我为所有文件尝试了各种类型的文件名,但是对于导航栏,这个问题仍然存在:\
标签: objective-c ipad uinavigationbar landscape ios5