2015-10-06 109 views
0

我正在爲越獄的iOS設備編寫一個調整設備,它與設備方向密切相關,它應該將整個屏幕設置爲指定的方向,並且保持該方向。這個調整運行在SpringBoardBackboardd之內,我嘗試了下面的代碼,但不起作用。有人知道嗎?如何強制旋轉iOS的屏幕?

NSNumber *value = [NSNumber numberWithInt:orientation]; 
[[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 
+0

也許可以使用這個代碼, 的NSNumber *值= [NSNumber的numberWithInt:UIInterfaceOrientationLandscapeLeft]; [[UIDevice currentDevice] setValue:value forKey:@「orientation」]; –

回答

-1

呼叫相同的代碼在viewDidAppear:方法(我下面寫的)。

目標C: -

NSNumber *value = [NSNumber numberWithInt:orientation]; 
[[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 

夫特: -

let value = UIInterfaceOrientation.orientation.rawValue 
UIDevice.currentDevice().setValue(value, forKey: "orientation") 
+0

哇!爲什麼要投票?請讓我知道先生的理由。 – pkc456

+0

謝謝你,但無奈,我說我試過這種方式。 – Suge

+0

您是否嘗試過viewDidAppear方法中的代碼? – pkc456