2011-08-03 29 views
0

我創建了一個簡單的導航應用程序。我允許應用程序的所有方向。問題如下 我在橫向方向。那麼我從RootViewController導航到一個UIViewController用於顯示PDF。當我在UiviewControoler中時,我將方向改爲肖像。並返回到RootViewController。此時RootViewController本身處於橫向模式,它顯示整個UI很糟糕。使用UINavigationControoler /導航應用程序時的UI方向問題

我真的不知道在網上搜索什麼。仍然我試圖搜索,但無法得到我的答案。任何人都可以告訴我如何解決這個問題?

+1

谷歌serach導航控制器的方向變化 – ram

+0

你應該看看presentModalViewController而不是pushViewController,因爲push假設方向相同,而現在沒有。 – msgambel

回答

0

首先您在應用程序委託文件中聲明布爾類型變量,然後在.m文件中設置屬性併合成。在APP-delegate.m文件ù

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
    toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
{ 
    MidwestTestAppDelegate *appDelegate = (MidwestTestAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    appDelegate.isLandscapeLeft = TRUE; 

} 
else 
{ 
    MidwestTestAppDelegate *appDelegate = (MidwestTestAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    appDelegate.isLandscapeLeft = FALSE; 


} 

} 在.m文件u使用此功能,給ü定向啓用與否。同樣你做視圖控制器。

+0

如果你沒有得到任何東西,然後告訴 – ram

+0

嘿ram謝謝! – KodeKiller

+0

我沒有得到一個變量的appDelegate。你能澄清一下嗎? – KodeKiller