iOSスクリーン回転各種コレクション(一)-単ページ回転
3472 ワード
回転を開く必要がある場合はまずinfoで回転を開く必要があります.plistポイント選択(方向が必要) Portrait Landscape Left Landscape Right
またはAppDelegateでエージェントメソッドを実装する
システムが提供するスタイル:plistと同じようにいろいろな組み合わせにほかならない.まず、システムがプログラムの起動プロセスUIKE処理画面で回転する流れを見てみましょう.加速計が方向変化を検出すると、U i D e v i c e O r i n t a t i o n DidChangeNotification通知が発行されます.このように、方向変化に関心のあるviewは、この通知を登録することで、デバイスの方向変化に応じて応答することができます.UIKEtは私たちに多くのことをしてくれて、スクリーンの回転を簡単にすることができます.UImitの対応する画面の回転の流れは以下の通りである:1、装置が回転する時、UImitは回転イベントを受信する.2、UImitはAppDelegateを通じて現在のプログラムのwindowを通知する.3、WindowはそのrootView Controlを知り、そのview controllerがサポートする回転方向を判断し、回転を完了する.4、ポップアップされたview controllerが存在する場合、ポップアップされたview controllerに基づいて回転するか否かを判断する.
こんなに長い間見ていたら、道理は分かりますが、どうやって使いますか.
****NAV PushViewController単独でページ****を設定
注意:UINavigationController親を使用して実装しないと、子VCは無効になります(理由は、UINavigationControllerがある場合rootView ControllerがUINavigationControllerであるためです).
親インプリメンテーションメソッドでは、個別のVCを使用して効果を得ることができます.
****Tabbat PushViewController単独でページを設定****
tabbr+navを有効にするには、同時に設定する必要があります.
サブクラス実装方法
PresentView Controlでページを個別に設定
iOS画面回転各種オムニバス(二)-単ページ部分回転***書きの比較的粗いdemo添付https://github.com/bloodspasm/ScreenRotation ***
またはAppDelegateでエージェントメソッドを実装する
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortraitUpsideDown;
}
システムが提供するスタイル:plistと同じようにいろいろな組み合わせにほかならない.
typedef NS_OPTIONS(NSUInteger, UIInterfaceOrientationMask) {
UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
}
こんなに長い間見ていたら、道理は分かりますが、どうやって使いますか.
****NAV PushViewController単独でページ****を設定
注意:UINavigationController親を使用して実装しないと、子VCは無効になります(理由は、UINavigationControllerがある場合rootView ControllerがUINavigationControllerであるためです).
親インプリメンテーションメソッドでは、個別のVCを使用して効果を得ることができます.
- (BOOL)shouldAutorotate
{
// topViewController VC
return self.topViewController.shouldAutorotate;
}
- (NSUInteger)supportedInterfaceOrientations
{
// topViewController VC
return self.topViewController.supportedInterfaceOrientations;
}
****Tabbat PushViewController単独でページを設定****
- (BOOL)shouldAutorotate {
return [self.selectedViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
return [self.selectedViewController supportedInterfaceOrientations];
}
tabbr+navを有効にするには、同時に設定する必要があります.
サブクラス実装方法
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
//
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL)shouldAutorotate
{
//
return YES;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
//
return UIInterfaceOrientationPortrait;
}
PresentView Controlでページを個別に設定
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
//
return UIInterfaceOrientationMaskAllButUpsideDown;
}
-(BOOL)shouldAutorotate
{
//
return YES;
}
iOS画面回転各種オムニバス(二)-単ページ部分回転***書きの比較的粗いdemo添付https://github.com/bloodspasm/ScreenRotation ***