是的,我知道這個問題已被問了很多次,但我找不到任何幫助我進一步的東西。如何強制我的iPhone應用程序保持特定的方向
使用具有3個viewcontrollers導航控制器,我需要從先前的屏幕保持數據,所以我不使用塞格斯但這樣的:
// When button is pressed
- (IBAction)changeView:(id)sender {
NSLog(@"Skipped connection screen");
ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondView"];
[self.navigationController pushViewController:vc animated:YES];
} 其中SecondView是視圖控制器的標識符應該出現。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
,並在我的項目,我的Info.plist添加了:因爲我只想旋轉是在合適的水平,我在每一個.m文件我有我的觀點的頂部添加此代碼段Initial interface orientation = Landscape (right home button
和我的項目設置中,我只添加了對此方向的支持。
問題是,當在iPhone上運行時,如果我以任何方式打開手機,方向會從橫向改變。當我嘗試將它恢復時,它只是不會。我想確保這個應用程序是從來沒有能夠遠離風景右轉。
有什麼建議嗎?非常感謝你提前。
請參閱我的下面的答案,讓我知道你是否有任何問題。 – Iducool