2013-10-25 34 views
0

嗨,我是新來的iOS開發...的UIViewController方向設置

我已經在項目創建僅支持橫向only.For,我用這樣的settings image

但是當我去打印鑑於尺寸

NSLog(@"%f--%f",self.view.frame.size.width,self.view.frame.size.height); 

在日誌給它

768.000000--1024.000000 

代替

1024.000000--768.000000 

,也是我加入了代碼

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
      { 
     BOOL res=((interfaceOrientation == UIInterfaceOrientationLandscapeLeft)||  (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); 
return res; 
     } 

我不知道如何解決這個problem.Please幫我在這

+0

SO有這個問題的答案負載。看到這個例子:http://stackoverflow.com/questions/12650137/how-to-change-the-device-orientation-programmatically-in-ios-6 – bizsytes

+0

我使用xcode5和ios7.0。它顯示錯誤'[UIDevice] setOrientation沒有Visible @Interface:'如何實現這個....? – sudheer

回答

1

有時甚至設置這樣的故障檢驗解決方案

在您的應用程序的屬性文件(YOURAPPNAME-Info.plist)中, 有一個名爲「支持的接口方向」的數組。 刪除陣列中您不想要的方向,並且您的應用將被鎖定到剩餘的方向。

在iOS 6中setOrientation折舊,則應該將其替換爲:

[[的UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

並返回僅適用於定位方法的景觀