0

ナビゲーションバーのビューをシフトして、予想されるパディングができるようにする方法はありますか?ポップオーバーフレームがナビゲーションバーの上部、左側、右側で重なっているように見えます。

これは、アプリのルートsplitViewControllerから派生したポップオーバーコントローラーのナビゲーションコントローラーです。<iOS5.1の問題です

コンテンツのナビゲーションバーをカバーするUIPopoverControllerのフレーム

4

1 に答える 1

0

解決策はUINavigationBarUIPopoverController. 準備ができたら、実装を投稿します。

アップデート

だからこれは面白いものです。iOS 4.x および iOS 5.0 は、本物の本物のポップオーバー、つまりフローティング ポップオーバーを使用します。navBar setBackgroundImageカスタム ナビゲーション バーは、このポップオーバー ( iOS 5.0 およびdrawRectiOS 4.x のカテゴリ オーバーライド) では機能しません。

ただし、5.1 では、カスタム ナビゲーション バーが適切に機能する「スライド オーバー」を使用します。実際はもっとすっきりしたデザインです。

とにかく、私のポイントは、縦向きで OS が 5.1 未満の場合にのみ、カスタム navBar フォーマットを削除する必要があるということです。通常、respondsToSelectorOS のバージョンを手動で把握する代わりに使用します。この場合、それは機能しません。

まだ iOS 4.x の修正に取り組んでいますが、iOS 5.0 は次のとおりです。

appDeleteカスタム navBar をセットアップするmyでは、次のようにします。

//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];
            }
        }
    }
}
于 2012-08-15T22:11:07.457 に答える