2011-10-20 56 views
0

我有一個不正確自動調整大小的按鈕。當它橫向左或右橫向時,我需要向右移動約100個像素。是否有捷徑可尋?我知道如何用JavaScript做到這一點,但不是客觀的。感謝您的幫助在iPad上的橫向移動按鈕?

回答

0

在您的控制器中實現viewDidLayoutSubviews方法並根據需要定位您的視圖。

+0

這是如何幫助我移動按鈕? – davis

+0

在該方法中,然後您可以確定您希望放置按鈕的位置並相應地設置它,例如, – Scott

+0

這樣的事情: 'UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; BOOL inLandscape = orientation == UIInterfaceOrientationLandscapeRight || oritentation == UIInterfaceOrientationLandscapeRight; CGFrame frame = CGRectMake(inLandscape?100.0:0,myControl.frame.size.width,myControl.frame.size.height);' 或類似的東西。 – Scott

0

我有時按照以下方式執行此操作,請根據需要插入代碼以移動控件。

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration{ 

    if (self.interfaceOrientation == UIDeviceOrientationPortrait || self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown) 
    { 
    //setup your interface for portrait 
    } 

else 

    if (self.interfaceOrientation == UIDeviceOrientationLandscapeLeft || self.interfaceOrientation == UIDeviceOrientationLandscapeRight) 
    { 
    //setup your interface for landscape 
    // your code to move buttons etc would go here 
    } 
} 
相關問題