回答

0

的解决方案是,当删除自定义UINavigationBar造型在UIPopoverController。准备好后我会发布实施。

更新

所以这是一个有趣的。 iOS 4.x和iOS 5.0使用真正的真正的popover,即浮动popover。自定义导航栏在此弹出窗口中不起作用(iOS 5.0中的navBar setBackgroundImage和iOS 4.x中的类别drawRect)。

但是,5.1使用了更多的“滑动式”,其中自定义导航栏很好地工作。实际上这是一个更清洁的设计。

无论如何,我的意思是,现在我需要删除自定义navBar格式,只有在肖像和操作系统是小于5.1。通常情况下,您需要使用respondsToSelector来代替手动计算操作系统版本。这在这种情况下不起作用。

仍然工作在iOS 4.x的修复,但这里的iOS 5.0:

在我appDelete,我在那里建立自定义导航栏:

//iOS 5.x: 
if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) 
{ 
    UIImage *image = [UIImage imageNamed:@"header.png"]; 
    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; 
} 

//iOS 4.x: 
@implementation UINavigationBar (CustomBackground) 
- (void)drawRect:(CGRect)rect 
{ 
    UIImage *image = [UIImage imageNamed:@"header.png"]; 
    [image drawInRect:CGRectMake(0, 0, 320, 44)]; 
} 
@end 

我设立观察员在didFinishLaunching

//start orientation notifications 
[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(didRotate:) 
              name:@"UIDeviceOrientationDidChangeNotification" 
              object:nil]; 
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
- (void) didRotate:(NSNotification *)notification 
{ 
    float version = [[[UIDevice currentDevice] systemVersion] floatValue]; 

    if (version < 5.1) 
    { 
     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 

     if (UIDeviceOrientationIsPortrait(orientation)) 
     { 
      if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) 
      { 
       [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; 
      } 
     } 
     else 
     { 
      if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) 
      { 
       UIImage *image = [UIImage imageNamed:@"header.png"]; 
       [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; 
      } 
     } 
    } 
}