ios 橫屏的時候顯示固定的 vc(視圖)

手機橫屏固定顯示某個頁面

手機 app 開啓橫屏, 橫屏的時候, 手機顯示固定的頁面, 無論app 在哪一個頁面橫屏顯示的始終是某個頁面

 

方法:1app

-(BOOL)shouldAutorotate{ide

return YES;server

}it

- (NSUInteger)supportedInterfaceOrientationsio

{object

return UIInterfaceOrientationMaskAll;select

}方法

注意該方法要寫在控制器的根視圖裏才生效notification

2.通知: (要想在哪一個頁面都實現這種方法寫在 APPdelegate 裏)view

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];

- (void)statusBarOrientationChange:(NSNotification *)notification{  UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

//在這個位置建立 view 或者 VC

if (orientation == UIInterfaceOrientationLandscapeRight) // home鍵靠右

{

//將 vc 或者 view 加到 window 上

}

if (orientation ==UIInterfaceOrientationLandscapeLeft) // home鍵靠左

{

//將 vc 或者 view 加到 window 上

}

if (orientation == UIInterfaceOrientationPortrait)

{

//將 vc 或者 view 從 window 上刪除

}

if (orientation == UIInterfaceOrientationPortraitUpsideDown)

{

//將 vc 或者 view 從 window 上刪除

}

}

相關文章
相關標籤/搜索