1

UISegmentControlに基づいてビューを切り替えるViewControllerに取り組んでいます。スタックオーバーフローに関するこの質問を見た後、オンラインでチュートリアルを見つけました

メインビューコントローラーはタブビューコントローラーであり、タブの1つに、セグメント化されたコントロールを含むuinavigationcontrollerがあります(まだ私と一緒にいることを願っています)。私が抱えている問題は、セグメント化されたコントロールのビューのビューの高さにあります。最初に選択されたビューは正しくサイズ変更されますが、セグメントコントロール内の他のすべてのビューは、そこにタブバーがあり、ビューがタブバーの下にあるという事実を無視します。

以下を追加してみましたが、役に立たないようです。

controller1.view.autoresizesSubviews = YES;
controller1.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

controller2.view.autoresizesSubviews = YES;
controller2.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

何か案は?

もう1つの問題は回転です。セグメント化されたビューで回転した場合。現在選択されているビューは回転します。セグメントを変更すると、ビューは横向きに回転せず、画面のごく一部しか占めません(以下を参照)。

SegmentedViewControllerのすべての回転関連メソッドを上書きし、管理しているビューの配列をループして、そこでメソッドを呼び出しました。残念ながら、これは仕事をしていないようです。

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

    for (UIViewController * viewController in self.segmentedViewControllers) 
        [viewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{
    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];    

    for (UIViewController * viewController in self.segmentedViewControllers) 
        [viewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];

}

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

    for (UIViewController * viewController in self.segmentedViewControllers) 
        [viewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];    
}

など…</p>

4

1 に答える 1

1

ここに示すように別の方法で実装することにより、この問題を解決することができましたhttp://redartisan.com/2010/6/27/uisegmented-control-view-switching-revisited

于 2012-10-13T22:14:33.143 に答える