2010-07-16 59 views
0

我有一個UILabel,我需要在應用程序啓動時向上移動大約50個像素(因爲它以縱向開始,我設計爲橫向),然後再次它被放回肖像。現在我使用基於當前幀的CGRect。問題是,當我嘗試旋轉手機的框架使用肖像值,並將標籤的方式關閉。我嘗試過使用其他一些方法,全部基於CGRect,並且他們將標籤保留在右側的軸上,但是它被轉移到了各處。同時我正在做這個,我也在改變字體的大小,所以我認爲這可能會影響一些東西。如何在iPhone旋轉後在屏幕上移動項目位置

我使用的代碼是:

//In ViewDidLoad 
CGRect defBox = self.seperator.frame; 

//On Rotation to Portriate 
CGRect newBox = self.seperator.frame; 
    newBox.origin.y += 50; 
    self.seperator.frame = newBox; 

//On Rotation to Landscape 
self.seperator.frame = defBox; 
+0

你在做什麼?在哪個回調? – 2010-07-16 11:19:38

+0

'willAnimateRotationToInterfaceOrientation()' – SeniorShizzle 2010-07-16 17:04:13

回答

0

使用self.separator.bounds,不self.separator.frame做它willAnimateRotationToInterfaceOrientation:didRotateFromInterfaceOrientation:

+0

謝謝。那就是訣竅 – SeniorShizzle 2010-07-18 00:22:47