Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在iPad上的UINavigationBar中以横向为中心的徽标_Ios_Ipad_Ios5_Uinavigationbar - Fatal编程技术网

Ios 在iPad上的UINavigationBar中以横向为中心的徽标

Ios 在iPad上的UINavigationBar中以横向为中心的徽标,ios,ipad,ios5,uinavigationbar,Ios,Ipad,Ios5,Uinavigationbar,在我的iPhone应用程序中,我有以下代码来设置应用程序中横向和纵向标题栏的背景图像 if ([UINavigationBar respondsToSelector:@selector(appearance)]) { [[UINavigationBar appearance] setBackgroundImage: [UIImage imageNamed:@"titlebar_landscape.png"] forBarMetrics:UIBarMetricsLandscapePhone

在我的iPhone应用程序中,我有以下代码来设置应用程序中横向和纵向标题栏的背景图像

if ([UINavigationBar respondsToSelector:@selector(appearance)]) {
    [[UINavigationBar appearance] setBackgroundImage: [UIImage imageNamed:@"titlebar_landscape.png"] forBarMetrics:UIBarMetricsLandscapePhone];
    [[UINavigationBar appearance] setBackgroundImage: [UIImage imageNamed:@"titlebar.png"] forBarMetrics:UIBarMetricsDefault];  
    [[UINavigationBar appearance] setBackgroundColor: [UIColor redColor]];
}
图像是以渐变背景为中心的应用程序徽标,该背景根据景观重新调整大小。我对我的iPad版应用程序也做了同样的操作,但是横向图像不起作用,因为iPad上没有像iPhone上那样的横向选项
UIBarMetricsLandscapePhone


因此,我的问题是如何在iOS5中,在横向模式下,在iPad上实现以渐变背景为中心的应用程序徽标的类似效果?

这是一个很好的教程,可能有助于为您指出正确的方向

无论方向如何,iPad都使用相同的条形图,因此您只需设置UIBarMetricsDefault图像。iPhone横向指标是因为在横向模式下,系统在iPhone上使用略短的导航栏。所有其他导航栏都是较大的,包括iPad上显示的任何导航栏。

我理解,但你没有回答这个问题。问题不在于iPad如何工作,问题在于如何在标题栏的横向视图中获得居中的图像?我假设您的图像是相同的,但经过调整以适应两种不同的高度。如果iPad上的横向模式必须有不同的背景图像,则必须在UIViewController子类中的willRotateToInterfaceOrientation:duration:方法中将其替换掉。由于iPad只使用了一个指标,你无法在UINavigationBar中获得自动交换行为,这是针对iPhone的。问题在于@john指出iPad在两个方向上使用相同的度量。这使得图像很难居中。苹果虫:这应该是可能的。如果我们仍然必须手动进行这种黑客攻击,那么外观系统是相当愚蠢的(我不知道苹果为什么没有注意到应用程序在不同的iPad方向上使用不同的背景——苹果自己做!)