2014-06-23 43 views
0

我已經使用xib創建了兩個ViewCrontroller,並且設置的方向爲UIViewsLandscapeLeft使用xib的狀態欄問題

,比這個代碼添加到

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

enter image description here

以下是我理想中的結果:

  1. 我想在狀態欄下的窗口中ios 7

  2. 第一視圖,結果是然而,當我跳到第二個視圖時,我想得到的是一個問題!窗口向左移20px。如何將其納入正常視圖?

3.大多數impornatant條件是Autolayout是 「TRUE」。

我的測試代碼: https://www.dropbox.com/s/bj9wg4hwar1t8y0/statusbartesting.zip

誰能幫助解決這個問題?

enter image description here

enter image description here

+0

你不應該改變這個框架窗口,但底層視圖的框架!請注意,自從iOS7以來,我們在每個視圖控制器上都有edgesForExtendedLayout屬性來處理這種行爲。此外,在故事板中,您可以取消選擇「延伸邊緣 - 頂部酒吧」等,以獲得您想要的 – Alexander

+0

@ Alexander,我將此代碼添加到我的項目中,但無法使用! if([[[UIDevice currentDevice] systemVersion] floatValue]> = 7.0){self.edgesForExtendedLayout = UIRectEdgeNone; self.extendedLayoutIncludesOpaqueBars = NO; } – nang531

+0

您是否使用導航控制器作爲容器?如果沒有,我會建議這樣做(你可以隱藏欄)請參閱http://stackoverflow.com/questions/18912290/how-to-present-a-view-controller-on-ios7-without-the-status-酒吧重疊 – Alexander

回答

0

你並不需要改變窗框中的AppDelegate。

我會告訴你的代碼,請跟着它

Appdelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    { 
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
     // Override point for customization after application launch. 
     self.window.backgroundColor = [UIColor whiteColor]; 
     [self.window makeKeyAndVisible]; 
     self.mxfirstciewcontroller = [[firstViewController alloc] initWithNibName:@"firstViewController" bundle:nil]; 

     self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:self.mxfirstciewcontroller]; 
     [(UINavigationController *)self.window.rootViewController setNavigationBarHidden:YES]; 

     return YES; 
    } 

在firstViewController.m

- (void)viewDidAppear:(BOOL)animated 
{ 

    [super viewDidAppear:animated]; 
    [self.view setFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height)]; 
} 

在secondViewController.m

- (void)viewDidAppear:(BOOL)animated{ 
    [super viewDidAppear:animated]; 

    [self.view setFrame:CGRectMake(20, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
} 
+0

@LorD Zsolt,@ Rohit爲什麼觀點有不同的取向?你有一個全球解決方案,也許爲窗口設置一些東西,不要設置爲每個視圖控制器! – nang531

+0

按照這個鏈接它會幫你http:// stackoverflow。COM /問題/ 9539676/UIViewController中,回報-無效幀 – Rohit