2012-07-05 30 views
0

我有一個應用程序,它具有一些按鈕,文本視圖和標籤。我想旋轉設備並讓它們在屏幕上重新繪製以適應。我想以編程方式進行。目前,我有以下方法:旋轉方向時重置框架

-(void)willRotateToInterfaceOrientation: 
(UIInterfaceOrientation)toInterfaceOrientation 
           duration:(NSTimeInterval)duration { 

    [super willRotateToInterfaceOrientation:toInterfaceOrientation 
            duration:duration]; 

    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || 
     toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 
     [self reOrderSideways]; 
    } else { 
     [self reOrderUpDown]; 
    } 
} 

-(void)reOrderSideways{ 
    self.viewLabel.frame=CGRectMake(175.0,140.0,130.0,20.0); 
    self.buttonOne.frame=CGRectMake(20.0,20.0,440.0,100.0); 
    self.buttonTwo.frame=CGRectMake(20.0,180.0,440.0,100.0); 
    self.textContent.frame=CGRectMake(20.0, 290.0, 440.0, 100.0); 
    self.theScroller.contentSize = CGSizeMake(480.0, 350.0); 
} 

-(void)reOrderUpDown{ 
    self.viewLabel.frame=CGRectMake(95.0,15.0,130.0,20.0); 
    self.buttonOne.frame=CGRectMake(20.0,50.0,280.0,190.0); 
    self.buttonTwo.frame=CGRectMake(20.0,250.0,280.0,190.0); 
    self.textContent.frame=CGRectMake(20.0, 450.0, 280.0, 190.0); 
    self.theScroller.contentSize = CGSizeMake(320.0, 460.0); 
} 

這完全不是那麼回事,因爲當我側身旋轉,按鈕和標籤和TextView的獲得截止右側。我檢查它,它看起來像它使用我給它的座標,但它仍然使用縱向框架或邊界。我怎樣才能解決這個問題?

回答

0

嘗試使用willAnimateRotationToInterfaceOrientation:代替。

+0

我得到同樣的問題 – marciokoko 2012-07-05 16:37:44