質問

私はこのiPhoneアプリと入れ子の設定のようになります:[RootViewController]->[UITabBarController]->[UINavigationController]->[subViewControllers].すべてが内蔵プログラムには、インターフェイスビルダを構築します。

私は単に対応できるようになるすべてのデバイスに方向性があります。すべての私AutoResizingマスクを設定し、全回転、拡大/契約が必要です。を除くすべてのNavigationControllerのnavBar、ツールバー.(通常、これらのビューの自動リサイズしないようにする向きを確認して下さい。すなわち景観のnavbar、ツールバーは自動的にリサイズ約32px、44pxにPortraiモードになります。) 何の特異なるのは、subViewのコントローラはサイズ変更が、実際のnavBar、ツールバーしています。つまり、コンテンツが伸び縮約12pxまたはそのいずれかの方向としてはnavbar、ツールバーのリサイズされます。-これにautoresizingマスクを進めています。

ってもらうためには、試みの大きな問題となったのでカテゴリーのためにUINavigationControllerに対応した'willRotateToInterfaceOrientation間"のためのトリガーのsizeToFit'セレクタをクローズします。(この技術から来たポストスタックオーバーフローを、同様の課題です。) また、私の研究の一番外側のビューコントローラーを受けこのメッセージをしない私の根ビューコントローラー電話ここにタブコントローラは、電話でのnavコントローラ等このたケアの問題は、今の私の子ビューのコントローラとの通知を受け、外観は転させます。のsizeToFit技術のnavバーとツールバーはサイズ変更。しかし、まだ紅葉の問題の削減のツールバーのためのオフセットのサイズチェンジが可能です。(当社のビューの座標にiPhoneを開始。)

このトリッキーなのwillRotate方法をいただいているのは、"いま、などの新しい境界観寸法まずはどんどん大きくなっています当社が現在向きです。している場合を除くdeviceOrientationNotifications onにして、僕はありません。) 全ての作業とは何か、という新しいオリエンテーションがどのツールバーの現在のフレームの値です。私はハードコードは、この計算フレームの調整は、昔ながらの方法を用のメモ用紙がていきたいと思っておりますの織りなすダイナミックなサイジングの特徴については仮定については、端末の画面にします。

そのため、以下のコードから受けることになってしまい治療するだけで'ぶつのツールバーによる12pxの相対サイズではますます高まりました。を防止するためにからぶつかり、ユーザが切り替える装置に使っている現在のツールバーのフレームの高さを導き出すための電流に向かう。(これだけを前提に関するツールバーの前後サイズがいよいかに影響を与える程ではないプログラムのサイズを変えるデバイスの物理的なアプリケーションです。

@implementation UINavigationController (BLUINavigationControllerAutoRotate)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return TRUE;
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

    // Resize the navBar
    [[self navigationBar] performSelector:@selector(sizeToFit)
                               withObject:nil
                               afterDelay:(0.5f * duration)];

    // Read our current frame size
    CGRect toolbarFrame = self.toolbar.frame;

    // Prevent over adjusting when flipping the device
    if ((toolbarFrame.size.height < 38
         && (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
             || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
        || (toolbarFrame.size.height > 38
            && (toInterfaceOrientation == UIInterfaceOrientationPortrait
                || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)))
    {
        // We are already resized and repositioned.
        return;
    }

    // Calculate and apply the toolbar offset
    const NSInteger delta = 12;     // the difference in size between 44 and 32 px.
    toolbarFrame.origin.y += ((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
                              || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) ? (delta) : (-delta);
    self.toolbar.frame = toolbarFrame;

    // Resize the toolbar
    [[self toolbar] performSelector:@selector(sizeToFit)
                         withObject:nil
                         afterDelay:(0.5f * duration)];

}

@end

そこで、私は正しく振る舞NavigationBar、ツールバー.から、エンドユーザーになることを知ったすべて実施すこのワーク周りのために再するかのように思われることができるので行動です。その後、私の質問は、なぜればいいのか。あうためのより良いアプローチを私にとって知っておくべきこ違いによるものなのか、それともいけないといけないとやっていな?([navigationController setAutomaticallyResizesToolbarOnrotate TRUE:];はいそうですよね。) のように言ったのは、このよう本イベントは終了いたしました。前に有線、いいんじゃないかといfinagleと転送メッセージおよび強制トリガーを感じるオーバースハックではなく、適切な解決策です。

よろしく!

役に立ちましたか?

解決

いを伝えるwillRotateToInterfaceOrientationメッセージのタブビューコントローラからルートビューコントローラには全てのその他の回転メッセージとを確認してくださいこ?すなわち

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [tabBarController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [tabBarController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation  {
    [super didRotateFromInterfaceOrientation:toInterfaceOrientation];
    [tabBarController didRotateFromInterfaceOrientation:toInterfaceOrientation];
}

- (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [super willAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [tabBarController willAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

- (void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    [super didAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation];
    [tabBarController didAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation];
}

- (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [super willAnimateSecondHalfOfRotationFromInterfaceOrientation:toInterfaceOrientation duration:duration];
    [tabBarController willAnimateSecondHalfOfRotationFromInterfaceOrientation:toInterfaceOrientation duration:duration];
}

さんに心に何が起こるか見てみてくださいればこれらすべてをタブバーのコントローラの問題をいかに実現されなければならな自動的にではなく、すべての余分の仕事だ。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top