2012-07-26 118 views
1

我正在使用基於UISegmentControl切換視圖的ViewController。我發現tutorial在線查看之後question on stack overflow使用控制器控制其他控制器時的視圖大小問題

主視圖控制器是一個選項卡視圖控制器,然後在其中一個選項卡上有一個包含分段控件(希望你仍然和我在一起)的uinavigationcontroller。 我遇到的問題是分段控件中視圖的高度。第一個選定的視圖被正確調整大小,但是段控制中的所有其他視圖都忽略了這樣一個事實,那裏有一個標籤欄,並且標籤欄下有視圖。

我已經嘗試添加以下內容,但它似乎沒有幫助。

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

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

任何想法?

另一個問題是旋轉。如果我在分段視圖上旋轉。當前選定的視圖將會旋轉,如果我改變了視圖,視圖將不會旋轉到橫向,並且只佔用屏幕的一小部分(如下所示)。

我覆蓋了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];  
} 

等等

回答

相關問題